Skip to content

Commit

Permalink
fix: updated to ternary operator insted of function
Browse files Browse the repository at this point in the history
  • Loading branch information
malmen237 committed Aug 30, 2024
1 parent 7224680 commit e8e091e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/api/manager/job/syncInventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,15 @@ export async function runSyncInventory() {
// If source was not found in response from API, always mark it as gone
return { ...inventorySource, status: 'gone' } satisfies WithId<Source>;
}
const statusUpdateCheck = () => {
const databaseStatus = inventorySource.status;
const apiStatus = apiSource.status;
if (apiStatus === 'new') {
return apiStatus;
} else if (databaseStatus === 'purge' && apiStatus === 'gone') {
return databaseStatus;
} else {
return apiStatus;
}
};

const databaseStatus = inventorySource.status;
const apiStatus = apiSource.status;
const isStatusGoneAndSetToPurge = databaseStatus === 'purge' && apiStatus === 'gone';

// Keep all old fields from the inventory source (name, tags, id, audio_stream etc), but update the status
return {
...inventorySource,
status: statusUpdateCheck()
status: isStatusGoneAndSetToPurge ? databaseStatus : apiStatus
} satisfies WithId<Source>;
});

Expand Down

0 comments on commit e8e091e

Please sign in to comment.