remove quote cursorscroll, chronological: sort by ts instead of id
This commit is contained in:
@@ -113,31 +113,13 @@ impl Quote {
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
pub fn get_chronological_cursorscroll(
|
||||
conn: &Connection,
|
||||
cursor: Option<Uuid>,
|
||||
amount: i64,
|
||||
) -> Result<Vec<Quote>, QuoteError> {
|
||||
let ids = match cursor {
|
||||
Some(c) => conn
|
||||
.prepare("SELECT id FROM quotes WHERE id < ?1 ORDER BY id DESC LIMIT ?2")?
|
||||
.query_map((c, amount), |r| r.get(0))?
|
||||
.collect::<Result<Vec<Uuid>, _>>()?,
|
||||
None => conn
|
||||
.prepare("SELECT id FROM quotes ORDER BY id DESC LIMIT ?1")?
|
||||
.query_map((amount,), |r| r.get(0))?
|
||||
.collect::<Result<Vec<Uuid>, _>>()?,
|
||||
};
|
||||
|
||||
ids.iter().map(|id| Self::get_by_id(conn, *id)).collect()
|
||||
}
|
||||
pub fn get_chronological_offset(
|
||||
conn: &Connection,
|
||||
offset: i64,
|
||||
limit: i64,
|
||||
) -> Result<Vec<Quote>, QuoteError> {
|
||||
let ids = conn
|
||||
.prepare("SELECT id FROM quotes ORDER BY id DESC LIMIT ?1 OFFSET ?2")?
|
||||
.prepare("SELECT id FROM quotes ORDER BY timestamp DESC LIMIT ?1 OFFSET ?2")?
|
||||
.query_map((limit, offset), |r| r.get(0))?
|
||||
.collect::<Result<Vec<Uuid>, _>>()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user