diff --git a/_migrations/2022-07-09-170014_tts_results_creation_index/down.sql b/_migrations/2022-07-09-170014_tts_results_creation_index/down.sql new file mode 100644 index 0000000000..5f8de8d4ac --- /dev/null +++ b/_migrations/2022-07-09-170014_tts_results_creation_index/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP INDEX `index_created_at` ON `tts_results`; diff --git a/_migrations/2022-07-09-170014_tts_results_creation_index/up.sql b/_migrations/2022-07-09-170014_tts_results_creation_index/up.sql new file mode 100644 index 0000000000..fbc363e626 --- /dev/null +++ b/_migrations/2022-07-09-170014_tts_results_creation_index/up.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +CREATE INDEX `index_created_at` ON `tts_results` (`created_at`); \ No newline at end of file diff --git a/analytics/most_popular_tts_models_time_period.sql b/analytics/most_popular_tts_models_time_period.sql new file mode 100644 index 0000000000..4e565d6fab --- /dev/null +++ b/analytics/most_popular_tts_models_time_period.sql @@ -0,0 +1,12 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +select m.token, m.title, r.use_count from ( + select model_token, count(*) as use_count from tts_results + where created_at < now() - interval 30 day + group by model_token + order by use_count desc limit 100 +) as r + join tts_models as m + on m.token = r.model_token; \ No newline at end of file