mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
reusable type
This commit is contained in:
1 parent
52af33a94d
commit
0aaacdddaa
4 files changed
+18
-13
No files matched your search
@@ -18,6 +18,7 @@ use tokens::tokens::users::*;
|
||||
use crate::http_server::common_responses::media_file_social_meta_lite::MediaFileSocialMetaLight;
|
||||
use crate::http_server::common_responses::pagination_cursors::PaginationCursors;
|
||||
use crate::http_server::common_responses::pagination_page::PaginationPage;
|
||||
use crate::http_server::common_responses::simple_entity_stats::SimpleEntityStats;
|
||||
use crate::http_server::common_responses::user_details_lite::{DefaultAvatarInfo, UserDetailsLight};
|
||||
use crate::http_server::endpoints::media_files::get_media_file::*;
|
||||
use crate::http_server::endpoints::media_files::list_featured_media_files::*;
|
||||
@@ -87,6 +88,7 @@ use crate::http_server::web_utils::response_success_helpers::*;
|
||||
MediaFileSocialMetaLight,
|
||||
PaginationCursors,
|
||||
PaginationPage,
|
||||
SimpleEntityStats,
|
||||
SimpleGenericJsonSuccess,
|
||||
UserDetailsLight,
|
||||
Visibility,
|
||||
@@ -105,7 +107,6 @@ use crate::http_server::web_utils::response_success_helpers::*;
|
||||
ListAvailableWeightsQuery,ListAvailableWeightsSuccessResponse,ModelWeightForList,
|
||||
ListWeightsByUserError,ListWeightsByUserSuccessResponse,ListWeightsByUserPathInfo,Weight,
|
||||
WeightsData,MediaFileData,
|
||||
BookmarkListStats,
|
||||
BatchGetUserRatingQueryParams,BatchGetUserRatingResponse,BatchGetUserRatingError,RatingRow,
|
||||
BatchGetUserBookmarksQueryParams,BatchGetUserBookmarksResponse,BatchGetUserBookmarksError,BookmarkRow,
|
||||
ListFeaturedMediaFilesSuccessResponse,MediaFile, ListFeaturedMediaFilesError,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod media_file_social_meta_lite;
|
||||
pub mod pagination_cursors;
|
||||
pub mod pagination_page;
|
||||
pub mod user_details_lite;
|
||||
pub mod media_file_social_meta_lite;
|
||||
pub mod simple_entity_stats;
|
||||
pub mod user_details_lite;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Simple stats that can be attached to any entity
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct SimpleEntityStats {
|
||||
/// Number of positive ratings (or "likes") for this item
|
||||
pub positive_rating_count: u32,
|
||||
/// Number of bookmarks for this item
|
||||
pub bookmark_count: u32,
|
||||
}
|
||||
+3
-10
@@ -23,6 +23,7 @@ use mysql_queries::queries::user_bookmarks::list_user_bookmarks::{list_user_book
|
||||
use tokens::tokens::user_bookmarks::UserBookmarkToken;
|
||||
|
||||
use crate::http_server::common_responses::pagination_page::PaginationPage;
|
||||
use crate::http_server::common_responses::simple_entity_stats::SimpleEntityStats;
|
||||
use crate::http_server::common_responses::user_details_lite::UserDetailsLight;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
use crate::server_state::ServerState;
|
||||
@@ -92,7 +93,7 @@ pub struct UserBookmarkDetailsForUserList {
|
||||
/// This is only populated if the item is a model weight.
|
||||
pub maybe_weight_data: Option<WeightsData>,
|
||||
|
||||
pub stats: BookmarkListStats,
|
||||
pub stats: SimpleEntityStats,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
@@ -122,14 +123,6 @@ pub struct WeightsData {
|
||||
pub maybe_creator: Option<UserDetailsLight>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct BookmarkListStats {
|
||||
/// Number of positive ratings (or "likes") for this item
|
||||
pub positive_rating_count: u32,
|
||||
/// Number of bookmarks for this item
|
||||
pub bookmark_count: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, ToSchema)]
|
||||
pub enum ListUserBookmarksForUserError {
|
||||
ServerError,
|
||||
@@ -272,7 +265,7 @@ pub async fn list_user_bookmarks_for_user_handler(
|
||||
// first-class system before handling the backfill here.
|
||||
maybe_thumbnail_url: None,
|
||||
|
||||
stats: BookmarkListStats {
|
||||
stats: SimpleEntityStats {
|
||||
positive_rating_count: user_bookmark.maybe_ratings_positive_count.unwrap_or(0),
|
||||
bookmark_count: user_bookmark.maybe_bookmark_count.unwrap_or(0),
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user