summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-07-04 15:48:47 -0700
committeriximeow <me@iximeow.net>2023-07-04 15:48:47 -0700
commit138800914aa38f25db2788a94a0327c692e29557 (patch)
tree52d9012ee59f912c3044788e4d25d091953753a5
parentc32adfb1956f89f7f778edce9e0367086080b058 (diff)
set a limit for how far back we'll construct new runs of existing jobs for new hosts
-rw-r--r--src/dbctx.rs10
-rw-r--r--src/sql.rs4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/dbctx.rs b/src/dbctx.rs
index f5f900a..e224310 100644
--- a/src/dbctx.rs
+++ b/src/dbctx.rs
@@ -549,10 +549,18 @@ impl DbCtx {
}
pub fn jobs_needing_task_runs_for_host(&self, host_id: u64) -> Result<Vec<Job>, String> {
+ // for jobs that this host has not run, we'll arbitrarily say that we won't generate new
+ // runs for jobs more than a day old.
+ //
+ // we don't want to rebuild the entire history every time we see a new host by default; if
+ // you really want to rebuild all of history on a new host, use `ci_ctl` to prepare the
+ // runs.
+ let cutoff = crate::io::now_ms() - 24 * 3600 * 1000;
+
let conn = self.conn.lock().unwrap();
let mut jobs_needing_task_runs = conn.prepare(sql::JOBS_NEEDING_HOST_RUN).unwrap();
- let mut job_rows = jobs_needing_task_runs.query([host_id]).unwrap();
+ let mut job_rows = jobs_needing_task_runs.query([cutoff, host_id]).unwrap();
let mut jobs = Vec::new();
while let Some(row) = job_rows.next().unwrap() {
diff --git a/src/sql.rs b/src/sql.rs
index e98c111..1071279 100644
--- a/src/sql.rs
+++ b/src/sql.rs
@@ -144,9 +144,9 @@ pub const PENDING_RUNS: &'static str = "\
pub const JOBS_NEEDING_HOST_RUN: &'static str = "\
select jobs.id, jobs.source, jobs.created_time, jobs.remote_id, jobs.commit_id, jobs.run_preferences from jobs \
- where jobs.run_preferences=\"all\" \
+ where jobs.run_preferences=\"all\" and jobs.created_time > ?1 \
and not exists \
- (select 1 from runs r2 where r2.job_id = jobs.id and r2.host_id = ?1);";
+ (select 1 from runs r2 where r2.job_id = jobs.id and r2.host_id = ?2);";
pub const ACTIVE_RUNS: &'static str = "\
select id,