mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-15 06:12:18 +00:00
stats for get weight handler
This commit is contained in:
1 parent
ae80d5c02d
commit
8b63c7e5bc
3 files changed
+35
-26
No files matched your search
@@ -43,11 +43,9 @@ pub struct RetrievedModelWeight {
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
//pub cached_user_ratings_negative_count: u32,
|
||||
//pub cached_user_ratings_positive_count: u32,
|
||||
//pub cached_user_ratings_total_count: u32,
|
||||
//pub maybe_cached_user_ratings_ratio: Option<f32>,
|
||||
//pub cached_user_ratings_last_updated_at: DateTime<Utc>,
|
||||
pub maybe_ratings_positive_count: Option<u32>,
|
||||
pub maybe_ratings_negative_count: Option<u32>,
|
||||
pub maybe_bookmark_count: Option<u32>,
|
||||
|
||||
pub version: i32,
|
||||
pub created_at: DateTime<Utc>,
|
||||
@@ -114,11 +112,9 @@ pub async fn get_weights_by_token_with_connection(
|
||||
maybe_cover_image_public_bucket_hash: record.maybe_cover_image_public_bucket_hash,
|
||||
maybe_cover_image_public_bucket_prefix: record.maybe_cover_image_public_bucket_prefix,
|
||||
maybe_cover_image_public_bucket_extension: record.maybe_cover_image_public_bucket_extension,
|
||||
//cached_user_ratings_negative_count: record.cached_user_ratings_negative_count,
|
||||
//cached_user_ratings_positive_count: record.cached_user_ratings_positive_count,
|
||||
//cached_user_ratings_total_count: record.cached_user_ratings_total_count,
|
||||
//maybe_cached_user_ratings_ratio: record.maybe_cached_user_ratings_ratio,
|
||||
//cached_user_ratings_last_updated_at: record.cached_user_ratings_last_updated_at,
|
||||
maybe_ratings_positive_count: record.maybe_ratings_positive_count,
|
||||
maybe_ratings_negative_count: record.maybe_ratings_negative_count,
|
||||
maybe_bookmark_count: record.maybe_bookmark_count,
|
||||
version: record.version,
|
||||
created_at: record.created_at,
|
||||
updated_at: record.updated_at,
|
||||
@@ -165,6 +161,10 @@ async fn select_include_deleted(
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
|
||||
entity_stats.ratings_positive_count as maybe_ratings_positive_count,
|
||||
entity_stats.ratings_negative_count as maybe_ratings_negative_count,
|
||||
entity_stats.bookmark_count as maybe_bookmark_count,
|
||||
|
||||
wt.version,
|
||||
wt.created_at,
|
||||
wt.updated_at,
|
||||
@@ -175,6 +175,9 @@ async fn select_include_deleted(
|
||||
ON users.token = wt.creator_user_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = wt.maybe_cover_image_media_file_token
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "model_weight"
|
||||
AND entity_stats.entity_token = wt.token
|
||||
WHERE
|
||||
wt.token = ?
|
||||
"#,
|
||||
@@ -221,6 +224,10 @@ async fn select_without_deleted(
|
||||
cover_image.maybe_public_bucket_prefix as maybe_cover_image_public_bucket_prefix,
|
||||
cover_image.maybe_public_bucket_extension as maybe_cover_image_public_bucket_extension,
|
||||
|
||||
entity_stats.ratings_positive_count as maybe_ratings_positive_count,
|
||||
entity_stats.ratings_negative_count as maybe_ratings_negative_count,
|
||||
entity_stats.bookmark_count as maybe_bookmark_count,
|
||||
|
||||
wt.version,
|
||||
wt.created_at,
|
||||
wt.updated_at,
|
||||
@@ -231,6 +238,9 @@ async fn select_without_deleted(
|
||||
ON users.token = wt.creator_user_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = wt.maybe_cover_image_media_file_token
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "model_weight"
|
||||
AND entity_stats.entity_token = wt.token
|
||||
WHERE
|
||||
wt.token = ?
|
||||
AND wt.user_deleted_at IS NULL
|
||||
@@ -271,11 +281,9 @@ pub struct RawWeight {
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
//pub cached_user_ratings_negative_count: u32,
|
||||
//pub cached_user_ratings_positive_count: u32,
|
||||
//pub cached_user_ratings_total_count: u32,
|
||||
//pub maybe_cached_user_ratings_ratio: Option<f32>,
|
||||
//pub cached_user_ratings_last_updated_at: DateTime<Utc>,
|
||||
pub maybe_ratings_positive_count: Option<u32>,
|
||||
pub maybe_ratings_negative_count: Option<u32>,
|
||||
pub maybe_bookmark_count: Option<u32>,
|
||||
|
||||
pub version: i32,
|
||||
pub created_at: DateTime<Utc>,
|
||||
|
||||
@@ -53,6 +53,8 @@ pub struct UserBookmark {
|
||||
pub maybe_model_weight_creator_gravatar_hash: Option<String>,
|
||||
|
||||
// TODO(bt,2023-12-30): I don't think these user fields are necessary.
|
||||
// We already know the user we're querying on behalf of, so presumably we
|
||||
// already have their info (ie. profile page use).
|
||||
pub user_token: UserToken,
|
||||
pub username: String,
|
||||
pub user_display_name: String,
|
||||
@@ -74,6 +76,8 @@ pub struct RawUserBookmarkRecord {
|
||||
pub (crate) entity_token: String,
|
||||
|
||||
// TODO(bt,2023-12-30): I don't think these user fields are necessary.
|
||||
// We already know the user we're querying on behalf of, so presumably we
|
||||
// already have their info (ie. profile page use).
|
||||
pub (crate) user_token: UserToken,
|
||||
pub (crate) username: String,
|
||||
pub (crate) user_display_name: String,
|
||||
|
||||
@@ -16,6 +16,7 @@ use enums::common::visibility::Visibility;
|
||||
use mysql_queries::queries::model_weights::get_weight::get_weight_by_token;
|
||||
use tokens::tokens::model_weights::ModelWeightToken;
|
||||
|
||||
use crate::http_server::common_responses::simple_entity_stats::SimpleEntityStats;
|
||||
use crate::http_server::common_responses::user_details_lite::UserDetailsLight;
|
||||
use crate::server_state::ServerState;
|
||||
|
||||
@@ -43,12 +44,9 @@ pub struct GetWeightResponse {
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
maybe_cover_image_public_bucket_path: Option<String>,
|
||||
|
||||
//cached_user_ratings_negative_count: u32,
|
||||
//cached_user_ratings_positive_count: u32,
|
||||
//cached_user_ratings_total_count: u32,
|
||||
//maybe_cached_user_ratings_ratio: Option<f32>,
|
||||
//cached_user_ratings_last_updated_at: DateTime<Utc>,
|
||||
|
||||
/// Statistics about the weights
|
||||
stats: SimpleEntityStats,
|
||||
|
||||
version: i32,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
@@ -183,11 +181,10 @@ pub async fn get_weight_handler(
|
||||
creator_set_visibility: weight.creator_set_visibility,
|
||||
file_size_bytes: weight.file_size_bytes,
|
||||
file_checksum_sha2: weight.file_checksum_sha2,
|
||||
//cached_user_ratings_negative_count: weight.cached_user_ratings_negative_count,
|
||||
//cached_user_ratings_positive_count: weight.cached_user_ratings_positive_count,
|
||||
//cached_user_ratings_total_count: weight.cached_user_ratings_total_count,
|
||||
//maybe_cached_user_ratings_ratio: weight.maybe_cached_user_ratings_ratio,
|
||||
//cached_user_ratings_last_updated_at: weight.cached_user_ratings_last_updated_at,
|
||||
stats: SimpleEntityStats {
|
||||
positive_rating_count: weight.maybe_ratings_positive_count.unwrap_or(0),
|
||||
bookmark_count: weight.maybe_bookmark_count.unwrap_or(0),
|
||||
},
|
||||
version: weight.version,
|
||||
created_at: weight.created_at,
|
||||
updated_at: weight.updated_at
|
||||
|
||||
Reference in new issue
Block a user