rename column

This commit is contained in:
Brandon Thomas committed 2021-06-07 00:47:42 -04:00
1 parent 94f8ab15bc
commit 7d02dc5e00
5 files changed
+16 -15

No files matched your search

+1 -1
View File
@@ -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.
@@ -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)
+10 -9
View File
@@ -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<String>,
pub maybe_video_object_name: Option<String>,
pub is_mod_approved: Option<bool>, // converted
pub is_mod_public_listing_approved: Option<bool>, // converted
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
@@ -36,7 +37,7 @@ struct RawW2lTemplateRecordForList {
pub duration_millis: i32,
pub maybe_public_bucket_preview_image_object_name: Option<String>,
pub maybe_public_bucket_preview_video_object_name: Option<String>,
pub is_mod_approved: Option<i8>, // NB: needs conversion
pub is_mod_public_listing_approved: Option<i8>, // NB: needs conversion
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
@@ -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
+2 -2
View File
@@ -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,
@@ -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 = ?