From 2e561acbb4b1efc829dbf160bf7980308abe8e60 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 7 Dec 2022 18:05:40 -0500 Subject: [PATCH] Analytics over top contributors, change loyalty plan slug --- analytics/user_top_contributors.sql | 43 +++++++++++++++++++ .../src/configs/plans/plan_list.rs | 6 +-- 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 analytics/user_top_contributors.sql diff --git a/analytics/user_top_contributors.sql b/analytics/user_top_contributors.sql new file mode 100644 index 0000000000..5f7274bfe2 --- /dev/null +++ b/analytics/user_top_contributors.sql @@ -0,0 +1,43 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +-- Top TTS model uploaders +select + u.id, + u.token, + u.username, + u.created_at, + u.maybe_loyalty_program_key, + m.upload_count +from users as u +join +( + select + count(*) as upload_count, + creator_user_token + from tts_models + group by creator_user_token + order by upload_count desc +) as m +on u.token = m.creator_user_token +where m.upload_count >= 5; + + + +-- Upgrade top TTS model uploaders to a loyalty plan +update users +set maybe_loyalty_program_key = 'fakeyou_contributor' +where token IN ( + select creator_user_token from + ( + select count(*) as upload_count, + creator_user_token + from tts_models + group by creator_user_token + having upload_count >= 10 + order by upload_count desc + ) as t +); + + diff --git a/crates/service/storyteller_web/src/configs/plans/plan_list.rs b/crates/service/storyteller_web/src/configs/plans/plan_list.rs index 7ae1f0b320..c86e2982e6 100644 --- a/crates/service/storyteller_web/src/configs/plans/plan_list.rs +++ b/crates/service/storyteller_web/src/configs/plans/plan_list.rs @@ -39,7 +39,7 @@ pub static FREE_LOGGED_IN_PLAN : Lazy = Lazy::new(|| { pub static LOYALTY_PLANS : Lazy> = Lazy::new(|| { let mut plans = HashSet::new(); - plans.insert(PlanBuilder::new("loyalty_plan") + plans.insert(PlanBuilder::new("fakeyou_contributor") .is_synthetic_plan(true) .plan_category(PlanCategory::LoyaltyReward) .tts_base_priority_level(2) @@ -319,7 +319,7 @@ mod test { assert_eq!(1, ALL_PLANS_BY_SLUG.get("free_logged_in").unwrap().tts_base_priority_level()); // Loyalty-based - assert_eq!(2, ALL_PLANS_BY_SLUG.get("loyalty_plan").unwrap().tts_base_priority_level()); + assert_eq!(2, ALL_PLANS_BY_SLUG.get("fakeyou_contributor").unwrap().tts_base_priority_level()); // Premium (Production) assert_eq!(10, ALL_PLANS_BY_SLUG.get("fakeyou_basic").unwrap().tts_base_priority_level()); @@ -341,7 +341,7 @@ mod test { assert_eq!(12, ALL_PLANS_BY_SLUG.get("free_logged_in").unwrap().tts_max_duration().num_seconds()); // Loyalty-based - assert_eq!(30, ALL_PLANS_BY_SLUG.get("loyalty_plan").unwrap().tts_max_duration().num_seconds()); + assert_eq!(30, ALL_PLANS_BY_SLUG.get("fakeyou_contributor").unwrap().tts_max_duration().num_seconds()); // Premium (Production) assert_eq!(30, ALL_PLANS_BY_SLUG.get("fakeyou_basic").unwrap().tts_max_duration().num_seconds());