Skip to content

Commit

Permalink
Make sqlite triggers use the end date column to identify jobs as fini…
Browse files Browse the repository at this point in the history
…shed
  • Loading branch information
saolof committed May 26, 2024
1 parent 21922d4 commit 3472c47
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions history_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ CREATE TRIGGER IF NOT EXISTS sequential_jobnumber AFTER INSERT ON jobruns
END;

CREATE TRIGGER IF NOT EXISTS last_seen_update AFTER UPDATE OF status ON jobruns
WHEN NEW.status in ('failed','completed')
WHEN NEW.ended <> ''
BEGIN
INSERT INTO last_db_status (database, last_seen, available)
VALUES (NEW.database, NEW.started, NEW.status <> 'failed')
VALUES (NEW.database, NEW.ended, NEW.status <> 'failed')
ON CONFLICT(database) DO UPDATE
SET last_seen = excluded.last_seen, available= excluded.available;
INSERT INTO last_finished_job_status (jobname, jobnumber, last_seen, succeeded)
VALUES (NEW.jobName, NEW.jobnumber ,NEW.started, NEW.status <> 'failed')
VALUES (NEW.jobName, NEW.jobnumber ,NEW.ended, NEW.status <> 'failed')
ON CONFLICT(jobname) DO UPDATE
SET jobnumber=excluded.jobnumber, last_seen = excluded.last_seen, succeeded= excluded.succeeded;
END;
Expand All @@ -49,4 +49,5 @@ CREATE TRIGGER IF NOT EXISTS clean_old_runs
AFTER UPDATE OF jobnumber ON last_finished_job_status
BEGIN
DELETE FROM jobruns WHERE jobName = NEW.jobname AND jobnumber < NEW.jobnumber - 1000;
END;
END;

0 comments on commit 3472c47

Please sign in to comment.