From 40a13182f708038eb3d15d054dfe367dfe0e0b7e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 30 Aug 2024 04:09:27 -0400 Subject: [PATCH] analytics queries (wip) --- .../backfill_job_product_categories.sql | 106 ++++++++++++++++++ .../databox_dashboards/product_by_day.sql | 7 ++ 2 files changed, 113 insertions(+) create mode 100644 _sql/actions_and_analytics/backfills/backfill_job_product_categories.sql create mode 100644 _sql/actions_and_analytics/databox_dashboards/product_by_day.sql diff --git a/_sql/actions_and_analytics/backfills/backfill_job_product_categories.sql b/_sql/actions_and_analytics/backfills/backfill_job_product_categories.sql new file mode 100644 index 0000000000..b6401091a4 --- /dev/null +++ b/_sql/actions_and_analytics/backfills/backfill_job_product_categories.sql @@ -0,0 +1,106 @@ +--- Analyze records +SELECT + job_type, + product_category, + inference_category, + maybe_model_type, + created_at +FROM generic_inference_jobs +WHERE product_category IS NULL +AND created_at >= '2024-08-25' +AND job_type NOT IN ('comfy_ui', 'stable_diffusion') +ORDER BY ID DESC +LIMIT 10; + +AND job_type NOT IN ('stable_diffusion', 'so_vits_svc', 'comfy_ui') + +--- Update tacotron2 jobs +UPDATE generic_inference_jobs +SET product_category = 'tts_tacotron2' +WHERE job_type = 'tacotron2' +AND inference_category = 'text_to_speech' +AND maybe_model_type = 'tacotron2' +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 1000; + + +--- Update tacotron2 jobs +UPDATE generic_inference_jobs +SET product_category = 'tts_tacotron2' +WHERE job_type = 'tacotron2' +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 1000; + +--- Update GptSoVits (#1) +UPDATE generic_inference_jobs +SET product_category = 'tts_gpt_so_vits' +WHERE job_type = 'gpt_sovits' +AND inference_category = 'text_to_speech' +AND maybe_model_type IS NULL +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 100000; + + +--- Update GptSoVits (#2: we changed the inference_category) +UPDATE generic_inference_jobs +SET product_category = 'tts_gpt_so_vits' +WHERE job_type = 'gpt_sovits' +AND inference_category = 'deprecated_field' +AND maybe_model_type IS NULL +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 100000; + + +--- Update RVCv2 VC jobs +UPDATE generic_inference_jobs +SET product_category = 'vc_rvc2' +WHERE job_type = 'rvc_v2' +AND inference_category = 'voice_conversion' +AND maybe_model_type = 'rvc_v2' +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 100000; + + +--- Update SVC VC jobs +UPDATE generic_inference_jobs +SET product_category = 'vc_svc' +WHERE job_type = 'so_vits_svc' +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 10000; + + +--- Update StyleTTS2 jobs +UPDATE generic_inference_jobs +SET product_category = 'tts_style_tts2' +WHERE job_type = 'styletts2' +AND inference_category = 'text_to_speech' +AND maybe_model_type = 'styletts2' +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 1000; + + +--- Update Live Portrait jobs +UPDATE generic_inference_jobs +SET product_category = 'live_portrait' +WHERE job_type = 'live_portrait' +AND inference_category = 'live_portrait' +AND maybe_model_type IS NULL +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 10000; + +--- Update SadTalker jobs +UPDATE generic_inference_jobs +SET product_category = 'lipsync_sad_talker' +WHERE maybe_model_type = 'sad_talker' +AND inference_category = 'lipsync_animation' +AND product_category IS NULL +AND created_at >= '2024-07-25' +LIMIT 100; diff --git a/_sql/actions_and_analytics/databox_dashboards/product_by_day.sql b/_sql/actions_and_analytics/databox_dashboards/product_by_day.sql new file mode 100644 index 0000000000..6cad7fc773 --- /dev/null +++ b/_sql/actions_and_analytics/databox_dashboards/product_by_day.sql @@ -0,0 +1,7 @@ +SELECT + DATE(gij.created_at) as created_date, + product_category, + count(*) as job_count +FROM generic_inference_jobs as gij +WHERE gij.created_at >= (CURDATE() - INTERVAL 30 DAY) +GROUP BY created_date, product_category;