Drop stats info from model weights (we'll do a JOIN soon)

This commit is contained in:
Brandon Thomas committed 2024-01-04 01:49:53 -05:00
1 parent 79cbeaffe0
commit 733fb9bf53
14 files changed
+249 -226

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
-- Statistics about any entity. Typically model weights and media files.
CREATE TABLE entity_stats (
-- Not used for anything except replication.
id BIGINT(20) NOT NULL AUTO_INCREMENT,
-- ========== ENTITY LINKAGE ==========
-- The type of record this is attached to
-- Currently supported values:
-- * 'model_weight'
-- * 'media_file'
-- * 'comment'
entity_type VARCHAR(32) NOT NULL,
-- The token for the record.
entity_token VARCHAR(32) NOT NULL,
-- ========== MODEL DESCRIPTION ==========
-- Total positive ratings
-- Total overall ratings = positive + negative
ratings_positive_count INT(10) UNSIGNED NOT NULL DEFAULT 0,
-- Total negative ratings
-- Total overall ratings = positive + negative
ratings_negative_count INT(10) UNSIGNED NOT NULL DEFAULT 0,
-- Total number of user bookmarks
bookmark_count INT(10) UNSIGNED NOT NULL DEFAULT 0,
-- Total number of views
-- view_count INT(10) UNSIGNED NOT NULL DEFAULT 0,
-- Total number of views
-- play_count INT(10) UNSIGNED NOT NULL DEFAULT 0,
-- ========== TIMESTAMPS ==========
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-- When the cached ratings were last calculated and updated.
-- maybe_last_backfilled_at TIMESTAMP DEFAULT NULL,
-- INDICES --
PRIMARY KEY (id),
UNIQUE KEY (entity_type, entity_token),
KEY index_entity_type (entity_type),
KEY index_entity_token (entity_token)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
@@ -116,10 +116,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
let mut private_bucket_prefix;
let mut private_bucket_extension;
let mut cached_user_ratings_total_count;
let mut cached_user_ratings_positive_count;
let mut cached_user_ratings_negative_count;
let mut cached_user_ratings_ratio;
//let mut cached_user_ratings_total_count;
//let mut cached_user_ratings_positive_count;
//let mut cached_user_ratings_negative_count;
//let mut cached_user_ratings_ratio;
let mut version;
match i {
@@ -142,10 +142,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
// private_bucket_hash = format!("bucket_hash{}", i);
private_bucket_prefix = format!("_fake");
private_bucket_extension = format!("rvcV2");
cached_user_ratings_total_count = i;
cached_user_ratings_positive_count = i;
cached_user_ratings_negative_count = i;
cached_user_ratings_ratio = i as u32 / 100;
//cached_user_ratings_total_count = i;
//cached_user_ratings_positive_count = i;
//cached_user_ratings_negative_count = i;
//cached_user_ratings_ratio = i as u32 / 100;
version = i as i32;
println!("Seeding RVCv2 model {}", i);
},
@@ -171,10 +171,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
private_bucket_prefix = format!("_fake");
private_bucket_extension = format!("tt2");
cached_user_ratings_total_count = i;
cached_user_ratings_positive_count = i;
cached_user_ratings_negative_count = i;
cached_user_ratings_ratio = i as u32 / 100;
//cached_user_ratings_total_count = i;
//cached_user_ratings_positive_count = i;
//cached_user_ratings_negative_count = i;
//cached_user_ratings_ratio = i as u32 / 100;
version = i as i32;
println!("Seeding TT2 model {}", i);
},
@@ -194,10 +194,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
private_bucket_prefix = format!("_fake");
private_bucket_extension = format!("sd15");
cached_user_ratings_total_count = i;
cached_user_ratings_positive_count = i;
cached_user_ratings_negative_count = i;
cached_user_ratings_ratio = i as u32 / 100;
//cached_user_ratings_total_count = i;
//cached_user_ratings_positive_count = i;
//cached_user_ratings_negative_count = i;
//cached_user_ratings_ratio = i as u32 / 100;
version = i as i32;
println!("Seeding SD15 model {}", i);
},
@@ -235,10 +235,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
original_filename = format!("filename{}.txt", i);
original_download_url = format!("https://civitai.com/api/download/models/149193?type=Model&format=SafeTensor&size=pruned&fp=fp16");
cached_user_ratings_total_count = i;
cached_user_ratings_positive_count = i;
cached_user_ratings_negative_count = i;
cached_user_ratings_ratio = i as u32 / 100;
//cached_user_ratings_total_count = i;
//cached_user_ratings_positive_count = i;
//cached_user_ratings_negative_count = i;
//cached_user_ratings_ratio = i as u32 / 100;
version = i as i32;
println!("Seeding SDXL model {}", i);
},
@@ -264,10 +264,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
private_bucket_prefix = format!("_fake");
private_bucket_extension = format!("loRA");
cached_user_ratings_total_count = i;
cached_user_ratings_positive_count = i;
cached_user_ratings_negative_count = i;
cached_user_ratings_ratio = i as u32 / 100;
//cached_user_ratings_total_count = i;
//cached_user_ratings_positive_count = i;
//cached_user_ratings_negative_count = i;
//cached_user_ratings_ratio = i as u32 / 100;
version = i as i32;
println!("Seeding LoRA model {}", i);
},
@@ -290,10 +290,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
// private_bucket_hash = format!("bucket_hash{}", i);
private_bucket_prefix = format!("_fake");
private_bucket_extension = format!("rvcV2");
cached_user_ratings_total_count = i;
cached_user_ratings_positive_count = i;
cached_user_ratings_negative_count = i;
cached_user_ratings_ratio = i as u32 / 100;
//cached_user_ratings_total_count = i;
//cached_user_ratings_positive_count = i;
//cached_user_ratings_negative_count = i;
//cached_user_ratings_ratio = i as u32 / 100;
version = i as i32;
println!("Out of range");
@@ -318,10 +318,10 @@ pub async fn seed_weights_for_paging(mysql_pool: &Pool<MySql>, user_token: UserT
public_bucket_hash: "bucket_hash1".to_string(),
maybe_public_bucket_prefix: Some(private_bucket_prefix),
maybe_public_bucket_extension: Some(private_bucket_extension),
cached_user_ratings_total_count,
cached_user_ratings_positive_count,
cached_user_ratings_negative_count,
maybe_cached_user_ratings_ratio: Some(cached_user_ratings_ratio as f32),
//cached_user_ratings_total_count,
//cached_user_ratings_positive_count,
//cached_user_ratings_negative_count,
//maybe_cached_user_ratings_ratio: Some(cached_user_ratings_ratio as f32),
version,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
};
@@ -363,10 +363,10 @@ pub async fn seed_weights_for_user_token(
public_bucket_hash: "bucket_hash1".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("rvc".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -388,10 +388,10 @@ pub async fn seed_weights_for_user_token(
public_bucket_hash: "bucket_hash2".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("tt2".to_string()),
cached_user_ratings_total_count: 20,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 2,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 20,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 2,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 2,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -413,10 +413,10 @@ pub async fn seed_weights_for_user_token(
public_bucket_hash: "bucket_hash3".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("safetensors".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -438,10 +438,10 @@ pub async fn seed_weights_for_user_token(
public_bucket_hash: "bucket_hash4".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("LoRA".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 2,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -463,10 +463,10 @@ pub async fn seed_weights_for_user_token(
public_bucket_hash: "bucket_hash4".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("LoRA".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 2,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
}
@@ -514,10 +514,10 @@ pub async fn original_seed_weights(mysql_pool: &Pool<MySql>, _user_token: UserTo
public_bucket_hash: "bucket_hash1".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("rvc".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -539,10 +539,10 @@ pub async fn original_seed_weights(mysql_pool: &Pool<MySql>, _user_token: UserTo
public_bucket_hash: "bucket_hash2".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("tt2".to_string()),
cached_user_ratings_total_count: 20,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 2,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 20,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 2,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 2,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -564,10 +564,10 @@ pub async fn original_seed_weights(mysql_pool: &Pool<MySql>, _user_token: UserTo
public_bucket_hash: "bucket_hash3".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("safetensors".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -589,10 +589,10 @@ pub async fn original_seed_weights(mysql_pool: &Pool<MySql>, _user_token: UserTo
public_bucket_hash: "bucket_hash4".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("LoRA".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 2,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
},
@@ -614,10 +614,10 @@ pub async fn original_seed_weights(mysql_pool: &Pool<MySql>, _user_token: UserTo
public_bucket_hash: "bucket_hash5".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("LoRA".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 2,
mysql_pool: &mysql_pool, // replace with actual MySqlPool
}
@@ -97,10 +97,10 @@ pub async fn seed_weights_files(
// let public_bucket_prefix = weights_type.to_string();
// let public_bucket_extension = weights_category.to_string();
let cached_user_ratings_total_count = n.clone();
let cached_user_ratings_positive_count = n.clone();
let cached_user_ratings_negative_count = n.clone();
let cached_user_ratings_ratio = 100.0 as f32;
//let cached_user_ratings_total_count = n.clone();
//let cached_user_ratings_positive_count = n.clone();
//let cached_user_ratings_negative_count = n.clone();
//let cached_user_ratings_ratio = 100.0 as f32;
let version = 1;
// get the abs path of the weights file to upload.
@@ -142,10 +142,10 @@ pub async fn seed_weights_files(
public_bucket_hash: bucket_hash,
maybe_public_bucket_prefix: Some(maybe_bucket_prefix.to_string()),
maybe_public_bucket_extension: Some(maybe_bucket_extension.to_string()),
cached_user_ratings_total_count,
cached_user_ratings_positive_count,
cached_user_ratings_negative_count,
maybe_cached_user_ratings_ratio: Some(cached_user_ratings_ratio),
//cached_user_ratings_total_count,
//cached_user_ratings_positive_count,
//cached_user_ratings_negative_count,
//maybe_cached_user_ratings_ratio: Some(cached_user_ratings_ratio),
version,
mysql_pool: &mysql_pool, // Assuming mysql_pool is defined elsewhere
};
@@ -34,11 +34,11 @@ pub struct ModelWeightDocument {
//pub description_markdown_html: String,
// TODO(bt,2023-12-22): Populate these fields
pub cached_user_ratings_total_count: u32,
pub cached_user_ratings_positive_count: u32,
pub cached_user_ratings_negative_count: u32,
pub cached_user_ratings_ratio: f32,
pub cached_user_ratings_last_updated_at: DateTime<Utc>,
//pub cached_user_ratings_total_count: u32,
//pub cached_user_ratings_positive_count: u32,
//pub cached_user_ratings_negative_count: u32,
//pub cached_user_ratings_ratio: f32,
//pub cached_user_ratings_last_updated_at: DateTime<Utc>,
pub creator_user_token: UserToken,
pub creator_username: String,
@@ -81,12 +81,6 @@ SET
maybe_public_bucket_prefix = ?,
maybe_public_bucket_extension = ?,
cached_user_ratings_total_count = 0,
cached_user_ratings_positive_count = 0,
cached_user_ratings_negative_count = 0,
maybe_cached_user_ratings_ratio = 0.0,
cached_user_ratings_last_updated_at = NOW(),
maybe_migration_old_model_token = ?
"#,
&weights_token,
@@ -26,10 +26,10 @@ pub struct CreateModelWeightsArgs<'a> {
pub public_bucket_hash: String,
pub maybe_public_bucket_prefix: Option<String>,
pub maybe_public_bucket_extension: 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>,
//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>,
pub version: i32,
pub mysql_pool: &'a MySqlPool,
}
@@ -59,10 +59,6 @@ pub async fn create_weight(args: CreateModelWeightsArgs<'_>) -> AnyhowResult<Mod
public_bucket_hash = ?,
maybe_public_bucket_prefix = ?,
maybe_public_bucket_extension = ?,
cached_user_ratings_total_count = ?,
cached_user_ratings_positive_count = ?,
cached_user_ratings_negative_count = ?,
maybe_cached_user_ratings_ratio = ?,
version = ?
"#,
args.token.as_str(),
@@ -82,10 +78,10 @@ pub async fn create_weight(args: CreateModelWeightsArgs<'_>) -> AnyhowResult<Mod
args.public_bucket_hash,
args.maybe_public_bucket_prefix,
args.maybe_public_bucket_extension,
args.cached_user_ratings_total_count,
args.cached_user_ratings_positive_count,
args.cached_user_ratings_negative_count,
args.maybe_cached_user_ratings_ratio,
//args.cached_user_ratings_total_count,
//args.cached_user_ratings_positive_count,
//args.cached_user_ratings_negative_count,
//args.maybe_cached_user_ratings_ratio,
args.version
)
.execute(args.mysql_pool).await;
@@ -43,11 +43,12 @@ 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 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 version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -113,11 +114,11 @@ 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,
//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,
version: record.version,
created_at: record.created_at,
updated_at: record.updated_at,
@@ -164,11 +165,6 @@ 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,
wt.cached_user_ratings_negative_count,
wt.cached_user_ratings_positive_count,
wt.cached_user_ratings_total_count,
wt.maybe_cached_user_ratings_ratio,
wt.cached_user_ratings_last_updated_at,
wt.version,
wt.created_at,
wt.updated_at,
@@ -225,11 +221,6 @@ 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,
wt.cached_user_ratings_negative_count,
wt.cached_user_ratings_positive_count,
wt.cached_user_ratings_total_count,
wt.maybe_cached_user_ratings_ratio,
wt.cached_user_ratings_last_updated_at,
wt.version,
wt.created_at,
wt.updated_at,
@@ -280,11 +271,12 @@ 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 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 version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -33,11 +33,11 @@ pub struct WeightsByTokensRecord {
pub maybe_cover_image_public_bucket_prefix: Option<String>,
pub maybe_cover_image_public_bucket_extension: 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>,
pub cached_user_ratings_last_updated_at: DateTime<Utc>,
//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>,
//pub cached_user_ratings_last_updated_at: DateTime<Utc>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -187,12 +187,11 @@ 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,
//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,
created_at: weight.created_at,
updated_at: weight.updated_at,
@@ -226,11 +225,11 @@ 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 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>,
pub cached_user_ratings_last_updated_at: DateTime<Utc>,
//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>,
//pub cached_user_ratings_last_updated_at: DateTime<Utc>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -267,11 +266,11 @@ 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")?,
//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")?,
created_at: row.try_get("created_at")?,
updated_at: row.try_get("updated_at")?,
user_deleted_at: row.try_get("user_deleted_at")?,
@@ -59,11 +59,11 @@ pub struct WeightJoinUser {
pub maybe_cover_image_public_bucket_prefix: Option<String>,
pub maybe_cover_image_public_bucket_extension: 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>,
pub cached_user_ratings_last_updated_at: DateTime<Utc>,
//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>,
//pub cached_user_ratings_last_updated_at: DateTime<Utc>,
pub version: i32,
@@ -237,11 +237,11 @@ impl ListWeightsQueryBuilder {
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_total_count: record.cached_user_ratings_total_count,
cached_user_ratings_positive_count: record.cached_user_ratings_positive_count,
cached_user_ratings_negative_count: record.cached_user_ratings_negative_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,
//cached_user_ratings_total_count: record.cached_user_ratings_total_count,
//cached_user_ratings_positive_count: record.cached_user_ratings_positive_count,
//cached_user_ratings_negative_count: record.cached_user_ratings_negative_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,
version: record.version,
created_at: record.created_at,
updated_at: record.updated_at,
@@ -287,11 +287,6 @@ impl ListWeightsQueryBuilder {
cover_image.public_bucket_directory_hash as maybe_cover_image_public_bucket_hash,
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,
model_weights.cached_user_ratings_total_count,
model_weights.cached_user_ratings_positive_count,
model_weights.cached_user_ratings_negative_count,
model_weights.maybe_cached_user_ratings_ratio,
model_weights.cached_user_ratings_last_updated_at,
model_weights.version,
model_weights.created_at,
model_weights.updated_at,
@@ -448,11 +443,11 @@ struct RawWeightJoinUser {
pub maybe_cover_image_public_bucket_prefix: Option<String>,
pub maybe_cover_image_public_bucket_extension: 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>,
pub cached_user_ratings_last_updated_at: DateTime<Utc>,
//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>,
//pub cached_user_ratings_last_updated_at: DateTime<Utc>,
pub version: i32,
@@ -92,11 +92,6 @@ SET
public_bucket_hash = ?,
maybe_public_bucket_prefix = ?,
maybe_public_bucket_extension = ?,
cached_user_ratings_total_count = 0,
cached_user_ratings_positive_count = 0,
cached_user_ratings_negative_count = 0,
maybe_cached_user_ratings_ratio = 0.0,
cached_user_ratings_last_updated_at = NOW(),
maybe_migration_old_model_token = ?,
version = ?,
@@ -123,11 +118,6 @@ ON DUPLICATE KEY UPDATE
public_bucket_hash = ?,
maybe_public_bucket_prefix = ?,
maybe_public_bucket_extension = ?,
cached_user_ratings_total_count = 0,
cached_user_ratings_positive_count = 0,
cached_user_ratings_negative_count = 0,
maybe_cached_user_ratings_ratio = 0.0,
cached_user_ratings_last_updated_at = NOW(),
maybe_migration_old_model_token = ?,
version = ?,
created_at = ?,
@@ -80,10 +80,10 @@ mod tests {
public_bucket_hash: "bucket_hash1".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("rvc".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &pool, // replace with actual MySqlPool
};
@@ -153,10 +153,10 @@ mod tests {
public_bucket_hash: "bucket_hash1".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("rvc".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &pool, // replace with actual MySqlPool
};
@@ -229,10 +229,10 @@ mod tests {
public_bucket_hash: "bucket_hash1".to_string(),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("rvc".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &pool, // replace with actual MySqlPool
};
@@ -294,6 +294,8 @@ mod tests {
page_index: 0,
sort_ascending: false,
view_as,
maybe_scoped_weight_type: None,
maybe_scoped_weight_category: None,
mysql_pool: &pool,
}).await?;
for weight in weights_by_username.records.iter() {
@@ -343,10 +345,10 @@ mod tests {
public_bucket_hash: format!("bucket_hash{}", i),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("rvc".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &pool, // replace with actual MySqlPool
};
@@ -585,10 +587,10 @@ mod tests {
public_bucket_hash: format!("bucket_hash{}", i),
maybe_public_bucket_prefix: Some("_fake".to_string()),
maybe_public_bucket_extension: Some("rvc".to_string()),
cached_user_ratings_total_count: 10,
cached_user_ratings_positive_count: 9,
cached_user_ratings_negative_count: 1,
maybe_cached_user_ratings_ratio: Some(0.9),
//cached_user_ratings_total_count: 10,
//cached_user_ratings_positive_count: 9,
//cached_user_ratings_negative_count: 1,
//maybe_cached_user_ratings_ratio: Some(0.9),
version: 1,
mysql_pool: &pool, // replace with actual MySqlPool
};
@@ -43,12 +43,11 @@ 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>,
//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>,
version: i32,
created_at: DateTime<Utc>,
@@ -184,11 +183,11 @@ 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,
//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,
version: weight.version,
created_at: weight.created_at,
updated_at: weight.updated_at
@@ -63,10 +63,10 @@ pub struct ModelWeightForList {
pub file_size_bytes: i32,
pub file_checksum_sha2: 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>,
//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>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -236,10 +236,10 @@ pub async fn list_available_weights_handler(
file_size_bytes: weight.file_size_bytes,
file_checksum_sha2: weight.file_checksum_sha2,
cached_user_ratings_total_count: weight.cached_user_ratings_total_count,
cached_user_ratings_positive_count: weight.cached_user_ratings_positive_count,
cached_user_ratings_negative_count: weight.cached_user_ratings_negative_count,
maybe_cached_user_ratings_ratio: weight.maybe_cached_user_ratings_ratio,
//cached_user_ratings_total_count: weight.cached_user_ratings_total_count,
//cached_user_ratings_positive_count: weight.cached_user_ratings_positive_count,
//cached_user_ratings_negative_count: weight.cached_user_ratings_negative_count,
//maybe_cached_user_ratings_ratio: weight.maybe_cached_user_ratings_ratio,
created_at: weight.created_at,
updated_at: weight.updated_at,
@@ -40,10 +40,10 @@ 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>,
//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>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -153,10 +153,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,
//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,
created_at: w.created_at,
updated_at: w.updated_at,
}