fix(parcel-sync): sync progress visible during GPKG/bundle export
3 bugs fixed: - syncLayer was called without jobId -> user saw no progress duringSync - syncLayer set status:'done' prematurely -> client stopped polling before GPKG phase - syncLayer errors were silently ignored -> confusing 'no features in DB' error Added isSubStep option to syncLayer: when true, keeps status as 'running' and doesn't schedule clearProgress. Export routes now pass jobId + isSubStep so the real sync progress (Descărcare features 50/200) is visible in the UI.
This commit is contained in:
@@ -196,13 +196,16 @@ export async function POST(req: Request) {
|
||||
: "Sync inițial";
|
||||
pushProgress();
|
||||
|
||||
await syncLayer(
|
||||
const syncResult = await syncLayer(
|
||||
validated.username,
|
||||
validated.password,
|
||||
validated.siruta,
|
||||
terenuriLayerId,
|
||||
{ forceFullSync: validated.forceSync },
|
||||
{ forceFullSync: validated.forceSync, jobId, isSubStep: true },
|
||||
);
|
||||
if (syncResult.status === "error") {
|
||||
throw new Error(syncResult.error ?? "Sync terenuri failed");
|
||||
}
|
||||
}
|
||||
updatePhaseProgress(1, 2);
|
||||
|
||||
@@ -214,13 +217,16 @@ export async function POST(req: Request) {
|
||||
: "Sync inițial";
|
||||
pushProgress();
|
||||
|
||||
await syncLayer(
|
||||
const syncResult = await syncLayer(
|
||||
validated.username,
|
||||
validated.password,
|
||||
validated.siruta,
|
||||
cladiriLayerId,
|
||||
{ forceFullSync: validated.forceSync },
|
||||
{ forceFullSync: validated.forceSync, jobId, isSubStep: true },
|
||||
);
|
||||
if (syncResult.status === "error") {
|
||||
throw new Error(syncResult.error ?? "Sync clădiri failed");
|
||||
}
|
||||
}
|
||||
updatePhaseProgress(2, 2);
|
||||
} else {
|
||||
@@ -233,6 +239,7 @@ export async function POST(req: Request) {
|
||||
/* ══════════════════════════════════════════════════════════ */
|
||||
/* Phase 2: Enrich (magic mode only) */
|
||||
/* ══════════════════════════════════════════════════════════ */
|
||||
// Take back progress control after syncLayer
|
||||
if (validated.mode === "magic") {
|
||||
setPhaseState("Verificare îmbogățire", weights.enrich, 1);
|
||||
|
||||
|
||||
@@ -180,13 +180,16 @@ export async function POST(req: Request) {
|
||||
: "Sync inițial de la eTerra";
|
||||
pushProgress();
|
||||
|
||||
await syncLayer(
|
||||
const syncResult = await syncLayer(
|
||||
validated.username,
|
||||
validated.password,
|
||||
validated.siruta,
|
||||
validated.layerId,
|
||||
{ forceFullSync: validated.forceSync },
|
||||
{ forceFullSync: validated.forceSync, jobId, isSubStep: true },
|
||||
);
|
||||
if (syncResult.status === "error") {
|
||||
throw new Error(syncResult.error ?? "Sync failed");
|
||||
}
|
||||
} else {
|
||||
note = "Date proaspete în baza de date — skip sync";
|
||||
pushProgress();
|
||||
@@ -195,6 +198,7 @@ export async function POST(req: Request) {
|
||||
finishPhase();
|
||||
|
||||
/* ── Phase 2: Build GPKG from local DB ── */
|
||||
// Take back progress control after syncLayer
|
||||
setPhaseState("Generare GPKG din baza de date", weights.gpkg, 1);
|
||||
|
||||
const features = await prisma.gisFeature.findMany({
|
||||
|
||||
Reference in New Issue
Block a user