From 7d02dc5e009ca48398c11a28e1d64e82f0d8f1c2 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 7 Jun 2021 00:47:42 -0400 Subject: [PATCH] rename column --- migrations/2021-05-15-071601_assets/up.sql | 2 +- .../list_w2l_inference_results.rs | 4 ++-- src/common_queries/list_w2l_templates.rs | 19 ++++++++++--------- src/common_queries/query_w2l_template.rs | 4 ++-- .../w2l/set_w2l_template_mod_approval.rs | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/migrations/2021-05-15-071601_assets/up.sql b/migrations/2021-05-15-071601_assets/up.sql index 243f5677ef..85a645256c 100644 --- a/migrations/2021-05-15-071601_assets/up.sql +++ b/migrations/2021-05-15-071601_assets/up.sql @@ -236,7 +236,7 @@ CREATE TABLE w2l_templates ( -- they're approved, but unapproved templates won't show up in public indices. -- This is independent of other visibility controls (is_mod_disabled, deleted_at, -- and creator_set_visibility) - is_mod_approved BOOLEAN DEFAULT NULL, + is_mod_public_listing_approved BOOLEAN DEFAULT NULL, -- In this case, a moderator disables it. -- This also disables it for the creator. diff --git a/src/common_queries/list_w2l_inference_results.rs b/src/common_queries/list_w2l_inference_results.rs index 8b21e82454..e81b91258c 100644 --- a/src/common_queries/list_w2l_inference_results.rs +++ b/src/common_queries/list_w2l_inference_results.rs @@ -159,7 +159,7 @@ LEFT OUTER JOIN users WHERE w2l_results.deleted_at IS NULL AND w2l_results.is_mod_hidden_from_public IS FALSE - AND w2l_templates.is_mod_approved IS TRUE + AND w2l_templates.is_mod_public_listing_approved IS TRUE "#) .fetch_all(mysql_pool) .await? @@ -241,7 +241,7 @@ LEFT OUTER JOIN users WHERE w2l_results.deleted_at IS NULL AND w2l_results.is_mod_hidden_from_public IS FALSE - AND w2l_templates.is_mod_approved IS TRUE + AND w2l_templates.is_mod_public_listing_approved IS TRUE AND users.username = ? "#, scope_creator_username) diff --git a/src/common_queries/list_w2l_templates.rs b/src/common_queries/list_w2l_templates.rs index 8377bb8ae3..4fd6e4cc8e 100644 --- a/src/common_queries/list_w2l_templates.rs +++ b/src/common_queries/list_w2l_templates.rs @@ -3,6 +3,7 @@ use chrono::{DateTime, Utc}; use crate::util::anyhow_result::AnyhowResult; use log::{warn, info}; use sqlx::MySqlPool; +use crate::database_helpers::boolean_converters::nullable_i8_to_optional_bool; #[derive(Serialize)] pub struct W2lTemplateRecordForList { @@ -18,7 +19,7 @@ pub struct W2lTemplateRecordForList { pub duration_millis: u32, pub maybe_image_object_name: Option, pub maybe_video_object_name: Option, - pub is_mod_approved: Option, // converted + pub is_mod_public_listing_approved: Option, // converted pub created_at: DateTime, pub updated_at: DateTime, } @@ -36,7 +37,7 @@ struct RawW2lTemplateRecordForList { pub duration_millis: i32, pub maybe_public_bucket_preview_image_object_name: Option, pub maybe_public_bucket_preview_video_object_name: Option, - pub is_mod_approved: Option, // NB: needs conversion + pub is_mod_public_listing_approved: Option, // NB: needs conversion pub created_at: DateTime, pub updated_at: DateTime, } @@ -93,7 +94,7 @@ pub async fn list_w2l_templates( duration_millis: if template.duration_millis > 0 { template.duration_millis as u32 } else { 0 }, maybe_image_object_name: template.maybe_public_bucket_preview_image_object_name.clone(), maybe_video_object_name: template.maybe_public_bucket_preview_video_object_name.clone(), - is_mod_approved: template.is_mod_approved.map(|v| if v == 0 { false } else { true }), + is_mod_public_listing_approved: nullable_i8_to_optional_bool(template.is_mod_public_listing_approved), created_at: template.created_at.clone(), updated_at: template.updated_at.clone(), } @@ -125,7 +126,7 @@ SELECT w2l.duration_millis, w2l.maybe_public_bucket_preview_image_object_name, w2l.maybe_public_bucket_preview_video_object_name, - w2l.is_mod_approved, + w2l.is_mod_public_listing_approved, w2l.created_at, w2l.updated_at FROM w2l_templates as w2l @@ -133,7 +134,7 @@ JOIN users ON users.token = w2l.creator_user_token WHERE w2l.deleted_at IS NULL - AND w2l.is_mod_approved IS TRUE + AND w2l.is_mod_public_listing_approved IS TRUE "#) .fetch_all(mysql_pool) .await? @@ -155,7 +156,7 @@ SELECT w2l.duration_millis, w2l.maybe_public_bucket_preview_image_object_name, w2l.maybe_public_bucket_preview_video_object_name, - w2l.is_mod_approved, + w2l.is_mod_public_listing_approved, w2l.created_at, w2l.updated_at FROM w2l_templates as w2l @@ -196,7 +197,7 @@ SELECT w2l.duration_millis, w2l.maybe_public_bucket_preview_image_object_name, w2l.maybe_public_bucket_preview_video_object_name, - w2l.is_mod_approved, + w2l.is_mod_public_listing_approved, w2l.created_at, w2l.updated_at FROM w2l_templates as w2l @@ -205,7 +206,7 @@ ON users.token = w2l.creator_user_token WHERE w2l.deleted_at IS NULL - AND w2l.is_mod_approved IS TRUE + AND w2l.is_mod_public_listing_approved IS TRUE AND users.username = ? "#, scope_creator_username) @@ -229,7 +230,7 @@ SELECT w2l.duration_millis, w2l.maybe_public_bucket_preview_image_object_name, w2l.maybe_public_bucket_preview_video_object_name, - w2l.is_mod_approved, + w2l.is_mod_public_listing_approved, w2l.created_at, w2l.updated_at FROM w2l_templates as w2l diff --git a/src/common_queries/query_w2l_template.rs b/src/common_queries/query_w2l_template.rs index 687ff8a1a9..c6fa76ca4c 100644 --- a/src/common_queries/query_w2l_template.rs +++ b/src/common_queries/query_w2l_template.rs @@ -125,7 +125,7 @@ SELECT w2l.duration_millis, w2l.maybe_public_bucket_preview_image_object_name, w2l.maybe_public_bucket_preview_video_object_name, - w2l.is_mod_approved as is_mod_public_listing_approved, + w2l.is_mod_public_listing_approved, w2l.is_mod_disabled, w2l.created_at, w2l.updated_at, @@ -161,7 +161,7 @@ SELECT w2l.duration_millis, w2l.maybe_public_bucket_preview_image_object_name, w2l.maybe_public_bucket_preview_video_object_name, - w2l.is_mod_approved as is_mod_public_listing_approved, + w2l.is_mod_public_listing_approved, w2l.is_mod_disabled, w2l.created_at, w2l.updated_at, diff --git a/src/http_server/endpoints/w2l/set_w2l_template_mod_approval.rs b/src/http_server/endpoints/w2l/set_w2l_template_mod_approval.rs index 7489bc35f7..3d3c85b9a8 100644 --- a/src/http_server/endpoints/w2l/set_w2l_template_mod_approval.rs +++ b/src/http_server/endpoints/w2l/set_w2l_template_mod_approval.rs @@ -135,7 +135,7 @@ pub async fn set_w2l_template_mod_approval_handler( r#" UPDATE w2l_templates SET - is_mod_approved = ?, + is_mod_public_listing_approved = ?, maybe_mod_user_token = ? WHERE token = ?