fix: keep up with the latest specs for since/until filter

This commit is contained in:
jiftechnify 2023-07-15 10:57:31 +09:00 committed by Greg Heartsfield
parent 9e22776227
commit c50e10aa21
2 changed files with 6 additions and 6 deletions

View File

@ -904,7 +904,7 @@ fn query_from_filter(f: &ReqFilter) -> Option<QueryBuilder<Postgres>> {
} }
push_and = true; push_and = true;
query query
.push("e.created_at > ") .push("e.created_at >= ")
.push_bind(Utc.timestamp_opt(f.since.unwrap() as i64, 0).unwrap()); .push_bind(Utc.timestamp_opt(f.since.unwrap() as i64, 0).unwrap());
} }
@ -915,7 +915,7 @@ fn query_from_filter(f: &ReqFilter) -> Option<QueryBuilder<Postgres>> {
} }
push_and = true; push_and = true;
query query
.push("e.created_at < ") .push("e.created_at <= ")
.push_bind(Utc.timestamp_opt(f.until.unwrap() as i64, 0).unwrap()); .push_bind(Utc.timestamp_opt(f.until.unwrap() as i64, 0).unwrap());
} }

View File

@ -1083,13 +1083,13 @@ fn query_from_filter(f: &ReqFilter) -> (String, Vec<Box<dyn ToSql>>, Option<Stri
kind_clause = String::new(); kind_clause = String::new();
}; };
if f.since.is_some() { if f.since.is_some() {
since_clause = format!("AND created_at > {}", f.since.unwrap()); since_clause = format!("AND created_at >= {}", f.since.unwrap());
} else { } else {
since_clause = String::new(); since_clause = String::new();
}; };
// Query for timestamp // Query for timestamp
if f.until.is_some() { if f.until.is_some() {
until_clause = format!("AND created_at < {}", f.until.unwrap()); until_clause = format!("AND created_at <= {}", f.until.unwrap());
} else { } else {
until_clause = String::new(); until_clause = String::new();
}; };
@ -1107,12 +1107,12 @@ fn query_from_filter(f: &ReqFilter) -> (String, Vec<Box<dyn ToSql>>, Option<Stri
} }
// Query for timestamp // Query for timestamp
if f.since.is_some() { if f.since.is_some() {
let created_clause = format!("created_at > {}", f.since.unwrap()); let created_clause = format!("created_at >= {}", f.since.unwrap());
filter_components.push(created_clause); filter_components.push(created_clause);
} }
// Query for timestamp // Query for timestamp
if f.until.is_some() { if f.until.is_some() {
let until_clause = format!("created_at < {}", f.until.unwrap()); let until_clause = format!("created_at <= {}", f.until.unwrap());
filter_components.push(until_clause); filter_components.push(until_clause);
} }
// never display hidden events // never display hidden events