projects: await syncToTurso + toStr() + log errores, quitar catch silencioso
This commit is contained in:
+18
-8
@@ -31,7 +31,7 @@ export const useProjectsStore = defineStore('projects', () => {
|
|||||||
initiative_name: p.initiative_name || p.name,
|
initiative_name: p.initiative_name || p.name,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
syncToTurso(projects.value)
|
await syncToTurso(projects.value)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
error.value = e.message
|
error.value = e.message
|
||||||
} finally {
|
} finally {
|
||||||
@@ -39,19 +39,29 @@ export const useProjectsStore = defineStore('projects', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toStr(v: unknown): string | null {
|
||||||
|
if (v === null || v === undefined) return null
|
||||||
|
return String(v)
|
||||||
|
}
|
||||||
|
|
||||||
async function syncToTurso(list: KappaInitiative[]) {
|
async function syncToTurso(list: KappaInitiative[]) {
|
||||||
|
console.log(`[Alpha] Syncing ${list.length} projects to Turso`)
|
||||||
for (const p of list) {
|
for (const p of list) {
|
||||||
|
try {
|
||||||
await tauriDb.saveProject({
|
await tauriDb.saveProject({
|
||||||
id: p.id,
|
id: Number(p.id) || 0,
|
||||||
name: p.initiative_name || p.name || `Proyecto ${p.id}`,
|
name: p.initiative_name || p.name || `Proyecto ${p.id}`,
|
||||||
key: p.key ?? null,
|
key: toStr(p.key),
|
||||||
description: p.description ?? null,
|
description: toStr(p.description),
|
||||||
status: p.status || 'active',
|
status: toStr(p.status) || 'active',
|
||||||
start_date: p.start_date ?? null,
|
start_date: toStr(p.start_date),
|
||||||
end_date: p.end_date ?? null,
|
end_date: toStr(p.end_date),
|
||||||
hus_count: null,
|
hus_count: null,
|
||||||
epics_count: null,
|
epics_count: null,
|
||||||
}).catch(() => {})
|
})
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`[Alpha] Failed to save project ${p.id}:`, e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user