Skip to content

feat(catalog-etl): consolidate terminal ETL scheduler into single sequential handler#289

Open
GitAddRemote wants to merge 1 commit into
mainfrom
feature/ISSUE-221
Open

feat(catalog-etl): consolidate terminal ETL scheduler into single sequential handler#289
GitAddRemote wants to merge 1 commit into
mainfrom
feature/ISSUE-221

Conversation

@GitAddRemote
Copy link
Copy Markdown
Owner

Summary

  • Replaces two independent @Cron methods (scheduledTerminalsSync at :00 and scheduledTerminalDistancesSync at :05) with a single scheduledTerminalEtl() at '0 * * * *'
  • terminals-sync runs first; any failure (error or ConflictException) aborts before attempting terminal-distances-sync, preventing wasted work on a partial state
  • ConflictException from either step is treated as a non-error condition: logs debug and returns cleanly — no error log noise
  • shouldSkip() is called independently for each step so a recently-completed terminal-distances-sync is still respected even when terminals-sync was not skipped

Test plan

  • 6-case unit spec added: sequential success, abort-on-terminals-sync failure, ConflictException handling for both steps, distances failure (resolves without throw), and per-step skip guard
  • All 6 tests pass locally
  • ESLint and Prettier clean (pre-commit hook passed)

Closes #221

…uential handler

- Replace two independent @Cron methods (terminals-sync at :00, terminal-distances-sync at :05) with a single scheduledTerminalEtl() at '0 * * * *'
- terminals-sync runs first; abort on failure or ConflictException before attempting distances
- ConflictException from either step logs debug (not error) and returns cleanly
- Add shouldSkip() guard for terminal-distances-sync so a recent run is respected independently
- Add 6-case spec covering sequential success, abort-on-failure, conflict handling, distances failure, and per-step skip guards

Closes #221
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates the terminal-related Catalog ETL scheduling logic into a single hourly cron handler to enforce step ordering in code (terminals first, then distances) and standardize error/lock handling behavior.

Changes:

  • Replaced two independent @Cron handlers with one scheduledTerminalEtl() running at 0 * * * *.
  • Implemented sequential execution with early abort on terminals-sync failure and debug-only handling for ConflictException.
  • Added unit tests covering the combined sequential scheduler behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
backend/src/modules/catalog-etl/schedulers/catalog-etl.scheduler.ts Consolidates terminal ETL cron scheduling into a single sequential handler and updates logging/error handling.
backend/src/modules/catalog-etl/schedulers/catalog-etl.scheduler.spec.ts Adds unit coverage for the new sequential scheduler behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +20
async scheduledTerminalEtl(): Promise<void> {
if (await this.shouldSkip('terminals-sync')) return;
this.logger.info('Starting scheduled terminals sync');
this.logger.info('Starting scheduled terminal ETL');

Comment on lines +68 to +72
it('skips when terminals-sync was completed within SKIP_HOURS', async () => {
mockGetLastSuccessfulStepRun.mockResolvedValue(new Date().toISOString());
await makeScheduler().scheduledTerminalEtl();
expect(mockRunStep).not.toHaveBeenCalled();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: consolidate terminal ETL scheduler into single sequential handler

2 participants