Skip to content

Commit

Permalink
Fix list query
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Feb 5, 2024
1 parent 238e500 commit 5fd5611
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
7 changes: 6 additions & 1 deletion rfd-cli/src/printer/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);
}
}

Expand Down
6 changes: 4 additions & 2 deletions rfd-model/src/storage/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<RfdRevisionModel>(&*self.pool.get().await?)
.await?;

Expand Down
16 changes: 15 additions & 1 deletion rfd-model/tests/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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();
}

0 comments on commit 5fd5611

Please sign in to comment.