Skip to content

Commit

Permalink
fix timestamp query to not be inclusive [staging]
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Calza <[email protected]>
  • Loading branch information
brunocalza committed Mar 20, 2024
1 parent 0dab234 commit 88693c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/worker/src/db/publications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ fn pub_cids_build_query(
query.push_bind(rel);

if *after > 0 {
query.push(" AND timestamp >= ");
query.push(" AND timestamp > ");
query.push_bind(after);
}

if *before > 0 {
query.push(" AND timestamp <= ");
query.push(" AND timestamp < ");
query.push_bind(before);
}

Expand All @@ -237,6 +237,6 @@ mod tests {
assert_eq!("SELECT cid, timestamp, expires_at FROM jobs JOIN namespaces ON namespaces.id = jobs.ns_id WHERE name = $1 AND relation = $2 ORDER BY jobs.id DESC LIMIT $3 OFFSET $4", sql);

let sql = pub_cids_build_query("ns", "rel", &1, &1, &1699395131, &1699395131);
assert_eq!("SELECT cid, timestamp, expires_at FROM jobs JOIN namespaces ON namespaces.id = jobs.ns_id WHERE name = $1 AND relation = $2 AND timestamp >= $3 AND timestamp <= $4 ORDER BY jobs.id DESC LIMIT $5 OFFSET $6", sql);
assert_eq!("SELECT cid, timestamp, expires_at FROM jobs JOIN namespaces ON namespaces.id = jobs.ns_id WHERE name = $1 AND relation = $2 AND timestamp > $3 AND timestamp < $4 ORDER BY jobs.id DESC LIMIT $5 OFFSET $6", sql);
}
}

0 comments on commit 88693c9

Please sign in to comment.