mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
Mapping list_weights_by_user.rs done need filter and then test
This commit is contained in:
1 parent
c9df278d40
commit
0e1e8a87f1
1 file changed
+87
-35
@@ -2,6 +2,7 @@ use std::os::linux::raw;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use chrono::{ DateTime, Utc };
|
||||
use enums::by_table::model_weights::weights_types;
|
||||
use log::{ info, warn };
|
||||
use sqlx::{ MySql, MySqlPool, query };
|
||||
use sqlx::pool::PoolConnection;
|
||||
@@ -19,40 +20,51 @@ use tokens::tokens::users::UserToken;
|
||||
#[derive(Serialize)]
|
||||
pub struct WeightsJoinUserRecord {
|
||||
pub token: ModelWeightToken,
|
||||
pub title: String,
|
||||
|
||||
pub weights_type: WeightsType,
|
||||
pub weights_category: WeightsCategory,
|
||||
|
||||
pub title: String,
|
||||
|
||||
pub maybe_thumbnail_token: Option<String>,
|
||||
|
||||
|
||||
pub description_markdown: String,
|
||||
pub description_rendered_html: String,
|
||||
|
||||
|
||||
pub creator_user_token: UserToken,
|
||||
pub creator_ip_address: String,
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
pub maybe_last_update_user_token: Option<UserToken>,
|
||||
|
||||
|
||||
pub original_download_url: Option<String>,
|
||||
pub original_filename: Option<String>,
|
||||
|
||||
pub file_size_bytes: i32,
|
||||
pub file_checksum_sha2: String,
|
||||
|
||||
pub private_bucket_hash: String,
|
||||
|
||||
pub maybe_private_bucket_prefix: Option<String>,
|
||||
pub maybe_private_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 version: i32,
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
|
||||
pub user_deleted_at: Option<DateTime<Utc>>,
|
||||
pub mod_deleted_at: Option<DateTime<Utc>>,
|
||||
|
||||
pub creator_username: String,
|
||||
pub creator_display_name: String,
|
||||
pub creator_email_gravatar_hash: String,
|
||||
|
||||
pub original_download_url: Option<String>,
|
||||
pub original_filename: Option<String>,
|
||||
pub file_size_bytes: i32,
|
||||
pub file_checksum_sha2: String,
|
||||
pub private_bucket_hash: String,
|
||||
pub maybe_private_bucket_prefix: Option<String>,
|
||||
pub maybe_private_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 version: i32,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub user_deleted_at: Option<DateTime<Utc>>,
|
||||
pub mod_deleted_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
pub async fn list_weights_by_username(
|
||||
@@ -86,9 +98,9 @@ pub async fn get_raw_weights_by_username(
|
||||
mw.description_markdown,
|
||||
mw.description_rendered_html,
|
||||
users.token as `creator_user_token: tokens::tokens::users::UserToken`,
|
||||
users.username as username,
|
||||
users.display_name as display_name,
|
||||
users.email_gravatar_hash as email_gravatar_hash,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
users.email_gravatar_hash as creator_email_gravatar_hash,
|
||||
mw.creator_ip_address,
|
||||
mw.creator_set_visibility as `creator_set_visibility: enums::common::visibility::Visibility`,
|
||||
mw.maybe_last_update_user_token as `maybe_last_update_user_token: tokens::tokens::users::UserToken`,
|
||||
@@ -131,9 +143,9 @@ pub async fn get_raw_weights_by_username(
|
||||
mw.description_markdown,
|
||||
mw.description_rendered_html,
|
||||
users.token as `creator_user_token: tokens::tokens::users::UserToken`,
|
||||
users.username as username,
|
||||
users.display_name as display_name,
|
||||
users.email_gravatar_hash as email_gravatar_hash,
|
||||
users.username as creator_username,
|
||||
users.display_name as creator_display_name,
|
||||
users.email_gravatar_hash as creator_email_gravatar_hash,
|
||||
mw.creator_ip_address,
|
||||
mw.creator_set_visibility as `creator_set_visibility: enums::common::visibility::Visibility`,
|
||||
mw.maybe_last_update_user_token as `maybe_last_update_user_token: tokens::tokens::users::UserToken`,
|
||||
@@ -168,13 +180,53 @@ pub async fn get_raw_weights_by_username(
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn map_to_weights() {
|
||||
pub async fn map_to_weights(dataset:Vec<RawWeightJoinUser>) -> Vec<WeightsJoinUserRecord> {
|
||||
let weights: Vec<WeightsJoinUserRecord> = dataset
|
||||
.into_iter()
|
||||
.map(|dataset: RawWeightJoinUser| {
|
||||
WeightsJoinUserRecord {
|
||||
token: dataset.token,
|
||||
title: dataset.title,
|
||||
weights_type: dataset.weights_type,
|
||||
weights_category: dataset.weights_category,
|
||||
maybe_thumbnail_token: dataset.maybe_thumbnail_token,
|
||||
description_markdown: dataset.description_markdown,
|
||||
description_rendered_html: dataset.description_rendered_html,
|
||||
|
||||
creator_user_token: dataset.creator_user_token,
|
||||
creator_ip_address: dataset.creator_ip_address,
|
||||
creator_set_visibility: dataset.creator_set_visibility,
|
||||
|
||||
maybe_last_update_user_token: dataset.maybe_last_update_user_token,
|
||||
original_download_url: dataset.original_download_url,
|
||||
original_filename: dataset.original_filename,
|
||||
file_size_bytes: dataset.file_size_bytes,
|
||||
file_checksum_sha2: dataset.file_checksum_sha2,
|
||||
private_bucket_hash: dataset.private_bucket_hash,
|
||||
maybe_private_bucket_prefix: dataset.maybe_private_bucket_prefix,
|
||||
maybe_private_bucket_extension: dataset.maybe_private_bucket_extension,
|
||||
|
||||
cached_user_ratings_negative_count: dataset.cached_user_ratings_negative_count,
|
||||
cached_user_ratings_positive_count: dataset.cached_user_ratings_positive_count,
|
||||
cached_user_ratings_total_count: dataset.cached_user_ratings_total_count,
|
||||
|
||||
maybe_cached_user_ratings_ratio: dataset.maybe_cached_user_ratings_ratio,
|
||||
cached_user_ratings_last_updated_at: dataset.cached_user_ratings_last_updated_at,
|
||||
version: dataset.version,
|
||||
created_at: dataset.created_at,
|
||||
updated_at: dataset.updated_at,
|
||||
user_deleted_at: dataset.user_deleted_at,
|
||||
mod_deleted_at: dataset.mod_deleted_at,
|
||||
|
||||
creator_username:dataset.creator_username,
|
||||
creator_display_name:dataset.creator_display_name,
|
||||
creator_email_gravatar_hash:dataset.creator_email_gravatar_hash
|
||||
}
|
||||
}).collect();
|
||||
|
||||
weights
|
||||
}
|
||||
|
||||
pub async fn filter_weights() {
|
||||
|
||||
}
|
||||
|
||||
pub async fn list_weights_by_username_with_connection(
|
||||
mysql_connection: &mut PoolConnection<MySql>,
|
||||
@@ -309,9 +361,9 @@ async fn list_datasets_by_creator_username(
|
||||
pub user_deleted_at: Option<DateTime<Utc>>,
|
||||
pub mod_deleted_at: Option<DateTime<Utc>>,
|
||||
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub email_gravatar_hash: String,
|
||||
pub creator_username: String,
|
||||
pub creator_display_name: String,
|
||||
pub creator_email_gravatar_hash: String,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user