[verified] fix(ordrestyring): stop scheduling unavailable hours endpoint

This commit is contained in:
alexpolo1
2026-10-04 07:34:29 +02:00
parent 4f125bbe9e
commit 38d35eb4cc
2 changed files with 10 additions and 9 deletions
@@ -228,7 +228,6 @@ describe('OrdrestyringSyncService.getSyncStatus', () => {
const stages = [
['syncCases', 1],
['syncUsers', 2],
['syncHours', 0],
['syncDebtors', 5],
['syncOfferSnapshots', 6],
['syncCaseFeatures', 8],
@@ -237,6 +236,7 @@ describe('OrdrestyringSyncService.getSyncStatus', () => {
stages.forEach(([name, changes]) => {
service[name] = jest.fn().mockResolvedValue({ hasChanges: changes > 0, changes });
});
service.syncHours = jest.fn().mockResolvedValue({ hasChanges: true, changes: 100 });
service.syncMaterials = jest.fn().mockResolvedValue({ hasChanges: true, changes: 100 });
service.syncCaseMaterialSnapshots = jest.fn().mockResolvedValue({ hasChanges: true, changes: 100 });
service.logSyncActivity = jest.fn().mockResolvedValue();
@@ -249,6 +249,7 @@ describe('OrdrestyringSyncService.getSyncStatus', () => {
expect.any(Number),
22
);
expect(service.syncHours).not.toHaveBeenCalled();
expect(service.syncMaterials).not.toHaveBeenCalled();
expect(service.syncCaseMaterialSnapshots).not.toHaveBeenCalled();
});
@@ -256,7 +257,7 @@ describe('OrdrestyringSyncService.getSyncStatus', () => {
test('records a failed stage as an incomplete run instead of a false success', async () => {
const service = new OrdrestyringSyncService();
const stages = [
'syncCases', 'syncUsers', 'syncHours', 'syncDebtors',
'syncCases', 'syncUsers', 'syncDebtors',
'syncOfferSnapshots', 'syncCaseFeatures', 'syncDashboardMetrics'
];
stages.forEach(name => {
@@ -271,7 +272,7 @@ describe('OrdrestyringSyncService.getSyncStatus', () => {
'error',
'Synchronization incomplete',
expect.any(Number),
5
4
);
});
@@ -281,13 +282,13 @@ describe('OrdrestyringSyncService.getSyncStatus', () => {
])('records a %s stage as incomplete instead of no_changes', async (_label, stageResult) => {
const service = new OrdrestyringSyncService();
const stages = [
'syncCases', 'syncUsers', 'syncHours', 'syncDebtors',
'syncCases', 'syncUsers', 'syncDebtors',
'syncOfferSnapshots', 'syncCaseFeatures', 'syncDashboardMetrics'
];
stages.forEach(name => {
service[name] = jest.fn().mockResolvedValue({ hasChanges: false, changes: 0 });
});
service.syncHours.mockResolvedValue(stageResult);
service.syncCases.mockResolvedValue(stageResult);
service.logSyncActivity = jest.fn().mockResolvedValue();
await service.performSync();
@@ -307,7 +308,7 @@ describe('OrdrestyringSyncService.getSyncStatus', () => {
])('keeps the authoritative run healthy when optional dashboard metrics %s', async (_label, dashboardResult, rejects) => {
const service = new OrdrestyringSyncService();
const coreStages = [
'syncCases', 'syncUsers', 'syncHours', 'syncDebtors',
'syncCases', 'syncUsers', 'syncDebtors',
'syncOfferSnapshots', 'syncCaseFeatures'
];
coreStages.forEach(name => {
@@ -126,11 +126,11 @@ class OrdrestyringSyncService {
let recordsProcessed = 0;
let syncIncomplete = false;
// Check and sync different data types
// The legacy REST /hours endpoint is documented as unavailable and is not an active writer.
// Historical hours remain read-only until a dedicated GraphQL mirror is implemented.
const syncResults = await Promise.allSettled([
this.syncCases(),
this.syncUsers(),
this.syncHours(),
this.syncDebtors(),
this.syncOfferSnapshots(),
this.syncCaseFeatures(),
@@ -139,7 +139,7 @@ class OrdrestyringSyncService {
// Process results
syncResults.forEach((result, index) => {
const dataType = ['cases', 'users', 'hours', 'debtors', 'offer_snapshots', 'case_features', 'dashboard_metrics'][index];
const dataType = ['cases', 'users', 'debtors', 'offer_snapshots', 'case_features', 'dashboard_metrics'][index];
const isAuthoritativeStage = dataType !== 'dashboard_metrics';
if (result.status === 'fulfilled') {
const stageChanges = Number(result.value?.changes);