Skip to content

Commit

Permalink
Merge pull request #312 from dkackman/nft-paging
Browse files Browse the repository at this point in the history
Nft paging improvements
  • Loading branch information
Rigidity authored Feb 2, 2025
2 parents e597216 + 7643192 commit 1c41312
Show file tree
Hide file tree
Showing 20 changed files with 833 additions and 391 deletions.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion crates/sage-api/src/requests/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ pub struct GetDidsResponse {

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[cfg_attr(feature = "tauri", derive(specta::Type))]
pub struct GetMinterDidIds {}
pub struct GetMinterDidIds {
pub offset: u32,
pub limit: u32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "tauri", derive(specta::Type))]
pub struct GetMinterDidIdsResponse {
pub did_ids: Vec<String>,
pub total: u32,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
Expand Down Expand Up @@ -147,6 +151,7 @@ pub struct GetNftCollections {
#[cfg_attr(feature = "tauri", derive(specta::Type))]
pub struct GetNftCollectionsResponse {
pub collections: Vec<NftCollectionRecord>,
pub total: u32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -182,6 +187,7 @@ pub struct GetNfts {
#[cfg_attr(feature = "tauri", derive(specta::Type))]
pub struct GetNftsResponse {
pub nfts: Vec<NftRecord>,
pub total: u32,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
Expand Down
15 changes: 15 additions & 0 deletions crates/sage-database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ impl Database {

Ok(())
}

/// Count collections, optionally including hidden ones
pub async fn count_collections(&self, include_hidden: bool) -> Result<i64> {
let count: i64 = if include_hidden {
sqlx::query_scalar!("SELECT COUNT(*) FROM collections")
.fetch_one(&self.pool)
.await?
} else {
sqlx::query_scalar!("SELECT COUNT(*) FROM collections WHERE visible = 1")
.fetch_one(&self.pool)
.await?
};

Ok(count)
}
}

#[derive(Debug)]
Expand Down
Loading

0 comments on commit 1c41312

Please sign in to comment.