fix: return pages in descending order of timestamp

This commit is contained in:
əlemi 2024-01-03 14:29:38 +01:00
parent 41f86634e5
commit 6fc27b47db
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -87,7 +87,7 @@ impl StorageProvider {
}
pub async fn extract(&self, offset: i32, window: i32, public: bool) -> sqlx::Result<Vec<PageView>> {
let out = sqlx::query_as::<_, Page>("SELECT * FROM pages WHERE public = $1 LIMIT $2 OFFSET $3")
let out = sqlx::query_as::<_, Page>("SELECT * FROM pages WHERE public = $1 ORDER BY timestamp DESC LIMIT $2 OFFSET $3")
.bind(if public { 1 } else { 0 }) // TODO since AnyPool won't handle booleans we compare with an integer
.bind(window)
.bind(offset)