diff --git a/rfd-cli/src/printer/tab.rs b/rfd-cli/src/printer/tab.rs index 687c6804..6dcc8854 100644 --- a/rfd-cli/src/printer/tab.rs +++ b/rfd-cli/src/printer/tab.rs @@ -652,7 +652,12 @@ impl TabDisplay for SearchResultHit { &s[..char_boundary] } - printer.print_field(tw, level, "content", &format!("{}...", get_slice_of_string(&self.content, 255))); + printer.print_field( + tw, + level, + "content", + &format!("{}...", get_slice_of_string(&self.content, 255)), + ); } } diff --git a/rfd-model/src/storage/postgres.rs b/rfd-model/src/storage/postgres.rs index 8782d647..10042be3 100644 --- a/rfd-model/src/storage/postgres.rs +++ b/rfd-model/src/storage/postgres.rs @@ -269,10 +269,12 @@ impl RfdRevisionStore for PostgresStore { query = query.filter(rfd_revision::deleted_at.is_null()); } - let results = query + let query = query .offset(pagination.offset) .limit(pagination.limit) - .order(rfd_revision::rfd_id.asc()) + .order((rfd_revision::rfd_id.asc(), rfd_revision::created_at.desc())); + + let results = query .get_results_async::(&*self.pool.get().await?) .await?; diff --git a/rfd-model/tests/postgres.rs b/rfd-model/tests/postgres.rs index 32ce2acf..f83044d9 100644 --- a/rfd-model/tests/postgres.rs +++ b/rfd-model/tests/postgres.rs @@ -15,7 +15,7 @@ use diesel_migrations::{embed_migrations, EmbeddedMigrations}; use rfd_model::{ storage::{ postgres::PostgresStore, ApiKeyFilter, ApiKeyStore, ApiUserFilter, ApiUserStore, - ListPagination, + ListPagination, RfdRevisionFilter, RfdRevisionStore, }, NewApiKey, NewApiUser, }; @@ -355,3 +355,17 @@ async fn test_api_user() { // ... #[tokio::test] async fn test_device_token() {} + +#[tokio::test] +async fn test_rfd_list() { + let db = TestDb::new("test_api_user"); + let store = PostgresStore::new(&db.url()).await.unwrap(); + + RfdRevisionStore::list_unique_rfd( + &store, + RfdRevisionFilter::default(), + &ListPagination::default(), + ) + .await + .unwrap(); +}