feat(wds): limit force sync to terenuri + cladiri only

Manual trigger now only processes sync_terenuri and sync_cladiri steps.
import_nogeom and enrich are left for the regular weekend window.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-30 07:36:35 +03:00
parent 145aa11c55
commit b8061ae31f
3 changed files with 21 additions and 7 deletions
@@ -277,8 +277,10 @@ type SessionLog = {
export async function runWeekendDeepSync(options?: {
force?: boolean;
onlySteps?: StepName[];
}): Promise<void> {
const force = options?.force ?? false;
const activeSteps = options?.onlySteps ?? STEPS;
const username = process.env.ETERRA_USERNAME;
const password = process.env.ETERRA_PASSWORD;
if (!username || !password) return;
@@ -327,7 +329,7 @@ export async function runWeekendDeepSync(options?: {
});
// Round-robin: iterate through steps, for each step iterate through cities
for (const stepName of STEPS) {
for (const stepName of activeSteps) {
// Find cities that still need this step
const needsStep = sorted.filter((c) => c.steps[stepName] === "pending");
if (needsStep.length === 0) continue;
@@ -633,7 +635,9 @@ async function sendStatusEmail(
* Resets error steps, clears lastSessionDate, and starts immediately.
* Uses an extended night window (22:0005:00) for the stillInWindow check.
*/
export async function triggerForceSync(): Promise<{ started: boolean; reason?: string }> {
export async function triggerForceSync(options?: {
onlySteps?: StepName[];
}): Promise<{ started: boolean; reason?: string }> {
if (g.__parcelSyncRunning) {
return { started: false, reason: "O sincronizare ruleaza deja" };
}
@@ -665,8 +669,11 @@ export async function triggerForceSync(): Promise<{ started: boolean; reason?: s
g.__parcelSyncRunning = true;
void (async () => {
try {
console.log("[weekend-sync] Force sync declansat manual.");
await runWeekendDeepSync({ force: true });
const stepNames = options?.onlySteps;
console.log(
`[weekend-sync] Force sync declansat manual.${stepNames ? ` Steps: ${stepNames.join(", ")}` : ""}`,
);
await runWeekendDeepSync({ force: true, onlySteps: stepNames });
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
console.error(`[weekend-sync] Force sync eroare: ${msg}`);