Skip to content
Snippets Groups Projects
Unverified Commit fd432b8e authored by Mathieu Othacehe's avatar Mathieu Othacehe
Browse files

Use specification for periodic builds.

When the periodic argument is passed to a job, it will be registered only if
the time difference between the current time and the registration time of the
last build is greater than the specified period. Make sure that the last job
that is searched is part of the same specification.

* src/sql/upgrade-16.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds_job_name_timestamp): New index.
* src/cuirass/database.scm (db-get-time-since-previous-build): Add
"specification" argument,
(db-register-builds): pass it.
parent e0f97e47
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,8 @@ dist_sql_DATA = \
src/sql/upgrade-12.sql \
src/sql/upgrade-13.sql \
src/sql/upgrade-14.sql \
src/sql/upgrade-15.sql
src/sql/upgrade-15.sql \
src/sql/upgrade-16.sql
dist_css_DATA = \
src/static/css/cuirass.css \
......
......@@ -734,7 +734,9 @@ path) VALUES ("
(#:starttime . 0)
(#:stoptime . 0))))
(if period
(let* ((time (db-get-time-since-previous-build job-name))
(let* ((spec (db-get-evaluation-specification eval-id))
(time
(db-get-time-since-previous-build job-name spec))
(add-build? (cond
((not time) #t)
((> time period) #t)
......@@ -1082,14 +1084,15 @@ ORDER BY ~a;"
(let ((key (if (number? derivation-or-id) 'id 'derivation)))
(expect-one-row (db-get-builds `((,key . ,derivation-or-id)))))))
(define (db-get-time-since-previous-build job-name)
(define (db-get-time-since-previous-build job-name specification)
"Return the time difference in seconds between the current time and the
registration time of the last build for JOB-NAME."
registration time of the last build for JOB-NAME and SPECIFICATION."
(with-db-worker-thread db
(let ((rows (sqlite-exec db "
SELECT strftime('%s', 'now') - timestamp FROM Builds
WHERE job_name = " job-name
"ORDER BY timestamp DESC LIMIT 1")))
SELECT strftime('%s', 'now') - Builds.timestamp FROM Builds
INNER JOIN Evaluations on Builds.evaluation = Evaluations.id
WHERE job_name = " job-name "AND specification = " specification
"ORDER BY Builds.timestamp DESC LIMIT 1")))
(and=> (expect-one-row rows) (cut vector-ref <> 0)))))
(define (db-add-event type timestamp details)
......
......@@ -99,6 +99,7 @@ CREATE TABLE Events (
-- an index. It is also preferable for the other tables.
CREATE INDEX Builds_status_index ON Builds (status);
CREATE INDEX Builds_evaluation_index ON Builds (evaluation, status);
CREATE INDEX Builds_job_name_timestamp on Builds(job_name, timestamp);
CREATE INDEX Builds_nix_name ON Builds (nix_name COLLATE NOCASE);
CREATE INDEX Builds_timestamp_stoptime on Builds(timestamp, stoptime);
CREATE INDEX Builds_stoptime on Builds(stoptime DESC);
......
BEGIN TRANSACTION;
CREATE INDEX Builds_job_name_timestamp on Builds(job_name, timestamp);
COMMIT;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment