mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
add stats to featured weights handler
This commit is contained in:
1 parent
e63f4e08bf
commit
70691437f3
2 files changed
+34
-19
No files matched your search
@@ -33,6 +33,10 @@ pub struct WeightsByTokensRecord {
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_ratings_positive_count: Option<u32>,
|
||||
pub maybe_ratings_negative_count: Option<u32>,
|
||||
pub maybe_bookmark_count: Option<u32>,
|
||||
|
||||
//pub cached_user_ratings_total_count: u32,
|
||||
//pub cached_user_ratings_positive_count: u32,
|
||||
//pub cached_user_ratings_negative_count: u32,
|
||||
@@ -88,6 +92,9 @@ async fn get_raw_weights_by_tokens(
|
||||
mw.cached_user_ratings_total_count,
|
||||
mw.maybe_cached_user_ratings_ratio,
|
||||
mw.cached_user_ratings_last_updated_at,
|
||||
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,
|
||||
mw.created_at,
|
||||
mw.updated_at,
|
||||
mw.user_deleted_at,
|
||||
@@ -97,6 +104,9 @@ async fn get_raw_weights_by_tokens(
|
||||
ON users.token = mw.creator_user_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = mw.maybe_cover_image_media_file_token
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "model_weights"
|
||||
AND entity_stats.entity_token = mw.token
|
||||
WHERE
|
||||
mw.creator_set_visibility = "public"
|
||||
AND mw.token IN (
|
||||
@@ -125,6 +135,9 @@ async fn get_raw_weights_by_tokens(
|
||||
mw.cached_user_ratings_total_count,
|
||||
mw.maybe_cached_user_ratings_ratio,
|
||||
mw.cached_user_ratings_last_updated_at,
|
||||
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,
|
||||
mw.created_at,
|
||||
mw.updated_at,
|
||||
mw.user_deleted_at,
|
||||
@@ -134,6 +147,9 @@ async fn get_raw_weights_by_tokens(
|
||||
ON users.token = mw.creator_user_token
|
||||
LEFT OUTER JOIN media_files as cover_image
|
||||
ON cover_image.token = mw.maybe_cover_image_media_file_token
|
||||
LEFT OUTER JOIN entity_stats
|
||||
ON entity_stats.entity_type = "model_weights"
|
||||
AND entity_stats.entity_token = mw.token
|
||||
WHERE
|
||||
mw.creator_set_visibility = "public"
|
||||
AND mw.user_deleted_at IS NULL
|
||||
@@ -187,11 +203,9 @@ fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsByTokensRecord>
|
||||
maybe_cover_image_public_bucket_prefix: weight.maybe_cover_image_public_bucket_prefix,
|
||||
maybe_cover_image_public_bucket_extension: weight.maybe_cover_image_public_bucket_extension,
|
||||
|
||||
//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,
|
||||
maybe_ratings_positive_count: weight.maybe_ratings_positive_count,
|
||||
maybe_ratings_negative_count: weight.maybe_ratings_negative_count,
|
||||
maybe_bookmark_count: weight.maybe_bookmark_count,
|
||||
|
||||
created_at: weight.created_at,
|
||||
updated_at: weight.updated_at,
|
||||
@@ -225,6 +239,10 @@ fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsByTokensRecord>
|
||||
pub maybe_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_ratings_positive_count: Option<u32>,
|
||||
pub maybe_ratings_negative_count: Option<u32>,
|
||||
pub maybe_bookmark_count: Option<u32>,
|
||||
|
||||
//pub cached_user_ratings_total_count: u32,
|
||||
//pub cached_user_ratings_positive_count: u32,
|
||||
//pub cached_user_ratings_negative_count: u32,
|
||||
@@ -266,11 +284,9 @@ impl FromRow<'_, MySqlRow> for RawWeightJoinUser {
|
||||
maybe_cover_image_public_bucket_hash: row.try_get("maybe_cover_image_public_bucket_hash")?,
|
||||
maybe_cover_image_public_bucket_prefix: row.try_get("maybe_cover_image_public_bucket_prefix")?,
|
||||
maybe_cover_image_public_bucket_extension: row.try_get("maybe_cover_image_public_bucket_extension")?,
|
||||
//cached_user_ratings_total_count: row.try_get("cached_user_ratings_total_count")?,
|
||||
//cached_user_ratings_positive_count: row.try_get("cached_user_ratings_positive_count")?,
|
||||
//cached_user_ratings_negative_count: row.try_get("cached_user_ratings_negative_count")?,
|
||||
//maybe_cached_user_ratings_ratio: row.try_get("maybe_cached_user_ratings_ratio")?,
|
||||
//cached_user_ratings_last_updated_at: row.try_get("cached_user_ratings_last_updated_at")?,
|
||||
maybe_ratings_positive_count: row.try_get("maybe_ratings_positive_count")?,
|
||||
maybe_ratings_negative_count: row.try_get("maybe_ratings_negative_count")?,
|
||||
maybe_bookmark_count: row.try_get("maybe_bookmark_count")?,
|
||||
created_at: row.try_get("created_at")?,
|
||||
updated_at: row.try_get("updated_at")?,
|
||||
user_deleted_at: row.try_get("user_deleted_at")?,
|
||||
|
||||
+8
-9
@@ -7,8 +7,8 @@ use chrono::{DateTime, Utc};
|
||||
use log::{debug, error, warn};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use utoipa::ToSchema;
|
||||
use buckets::public::media_files::bucket_file_path::MediaFileBucketPath;
|
||||
|
||||
use buckets::public::media_files::bucket_file_path::MediaFileBucketPath;
|
||||
use enums::by_table::model_weights::{
|
||||
weights_category::WeightsCategory,
|
||||
weights_types::WeightsType,
|
||||
@@ -16,6 +16,7 @@ use enums::by_table::model_weights::{
|
||||
use mysql_queries::queries::model_weights::list::list_weights_by_tokens::list_weights_by_tokens;
|
||||
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;
|
||||
|
||||
@@ -40,10 +41,8 @@ pub struct ModelWeightForList {
|
||||
/// If a cover image is set, this is the path to the asset.
|
||||
pub maybe_cover_image_public_bucket_path: Option<String>,
|
||||
|
||||
//pub cached_user_ratings_total_count: u32,
|
||||
//pub cached_user_ratings_positive_count: u32,
|
||||
//pub cached_user_ratings_negative_count: u32,
|
||||
//pub maybe_cached_user_ratings_ratio: Option<f32>,
|
||||
/// Statistics about the weights
|
||||
pub stats: SimpleEntityStats,
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
@@ -153,10 +152,10 @@ pub async fn list_featured_weights_handler(
|
||||
&w.creator_display_name,
|
||||
&w.creator_email_gravatar_hash
|
||||
),
|
||||
//cached_user_ratings_total_count: w.cached_user_ratings_total_count,
|
||||
//cached_user_ratings_positive_count: w.cached_user_ratings_positive_count,
|
||||
//cached_user_ratings_negative_count: w.cached_user_ratings_negative_count,
|
||||
//maybe_cached_user_ratings_ratio: w.maybe_cached_user_ratings_ratio,
|
||||
stats: SimpleEntityStats {
|
||||
positive_rating_count: w.maybe_ratings_positive_count.unwrap_or(0),
|
||||
bookmark_count: w.maybe_bookmark_count.unwrap_or(0),
|
||||
},
|
||||
created_at: w.created_at,
|
||||
updated_at: w.updated_at,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user