fix: allow store refresh progress to advance beyond 95% until completion
This commit is contained in:
10
src/App.js
10
src/App.js
@@ -398,7 +398,11 @@ function App() {
|
|||||||
if (job?.status === 'running') {
|
if (job?.status === 'running') {
|
||||||
const total = job.total || 0;
|
const total = job.total || 0;
|
||||||
const processed = job.processed || 0;
|
const processed = job.processed || 0;
|
||||||
const percent = total > 0 ? Math.min(95, 10 + Math.round((processed / total) * 80)) : undefined;
|
let percent;
|
||||||
|
if (total > 0) {
|
||||||
|
const ratio = Math.max(0, Math.min(1, processed / total));
|
||||||
|
percent = Math.min(99, 5 + Math.round(ratio * 90));
|
||||||
|
}
|
||||||
let etaSeconds = null;
|
let etaSeconds = null;
|
||||||
if (total > 0 && processed > 0) {
|
if (total > 0 && processed > 0) {
|
||||||
const elapsedSeconds = Math.max(1, (Date.now() - jobStartedAt) / 1000);
|
const elapsedSeconds = Math.max(1, (Date.now() - jobStartedAt) / 1000);
|
||||||
@@ -414,7 +418,7 @@ function App() {
|
|||||||
updateSyncProgress(message, percent, { etaSeconds });
|
updateSyncProgress(message, percent, { etaSeconds });
|
||||||
} else if (!job) {
|
} else if (!job) {
|
||||||
if (statusData.storesFresh) {
|
if (statusData.storesFresh) {
|
||||||
updateSyncProgress('Betriebe aktuell.', 90, { etaSeconds: null });
|
updateSyncProgress('Betriebe aktuell.', 99, { etaSeconds: null });
|
||||||
completed = true;
|
completed = true;
|
||||||
} else if (!jobStarted) {
|
} else if (!jobStarted) {
|
||||||
await triggerRefresh();
|
await triggerRefresh();
|
||||||
@@ -423,7 +427,7 @@ function App() {
|
|||||||
updateSyncProgress('Warte auf Rückmeldung...', undefined, { etaSeconds: null });
|
updateSyncProgress('Warte auf Rückmeldung...', undefined, { etaSeconds: null });
|
||||||
}
|
}
|
||||||
} else if (job.status === 'done') {
|
} else if (job.status === 'done') {
|
||||||
updateSyncProgress('Synchronisierung abgeschlossen', 95, { etaSeconds: null });
|
updateSyncProgress('Synchronisierung abgeschlossen', 100, { etaSeconds: null });
|
||||||
completed = true;
|
completed = true;
|
||||||
} else if (job.status === 'error') {
|
} else if (job.status === 'error') {
|
||||||
throw new Error(job.error || 'Unbekannter Fehler beim Prüfen der Betriebe.');
|
throw new Error(job.error || 'Unbekannter Fehler beim Prüfen der Betriebe.');
|
||||||
|
|||||||
Reference in New Issue
Block a user