Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Recreate the audioset matview after full popularity recalculation (#493)
Staci Cooper25c25d5be11a
diff --git a/env.template b/env.templateindex bb6cd5f45..abebdc682 100644--- a/env.template+++ b/env.template@@ -64,8 +64,9 @@ AIRFLOW_CONN_EMR_TEST=emr://?host=http://s3:5000EMR_CONN_ID=emr_emptyEMR_TEST_CONN_ID=emr_test-# Connection to the Ingestion Server, used for managing data refreshes.-AIRFLOW_CONN_DATA_REFRESH=not_set+# Connection to the Ingestion Server, used for managing data refreshes. Default is used to+# connect to your locally running ingestion server.+AIRFLOW_CONN_DATA_REFRESH=http://172.17.0.1:8001########################################################################################diff --git a/openverse_catalog/dags/common/popularity/sql.py b/openverse_catalog/dags/common/popularity/sql.pyindex 89040e409..466a9ad14 100644--- a/openverse_catalog/dags/common/popularity/sql.py+++ b/openverse_catalog/dags/common/popularity/sql.py@@ -11,6 +11,7 @@ DEFAULT_PERCENTILE = 0.85IMAGE_VIEW_NAME = "image_view"AUDIO_VIEW_NAME = "audio_view"+AUDIOSET_VIEW_NAME = "audioset_view"IMAGE_POPULARITY_CONSTANTS_VIEW = "image_popularity_constants"AUDIO_POPULARITY_CONSTANTS_VIEW = "audio_popularity_constants"IMAGE_POPULARITY_PERCENTILE_FUNCTION = "image_popularity_percentile"@@ -299,6 +300,31 @@ def create_standardized_media_popularity_function(postgres.run(query)+def create_audioset_view_query():+ """+ Returns SQL to create the audioset_view.+ """+ return dedent(+ f"""+ CREATE VIEW public.{AUDIOSET_VIEW_NAME}+ AS+ SELECT DISTINCT+ (audio_set ->> 'foreign_identifier') :: varchar(1000) as foreign_identifier,+ (audio_set ->> 'title') :: varchar(2000) as title,+ (audio_set ->> 'foreign_landing_url') :: varchar(1000) as foreign_landing_url,+ (audio_set ->> 'creator') :: varchar(2000) as creator,+ (audio_set ->> 'creator_url') :: varchar(2000) as creator_url,+ (audio_set ->> 'url') :: varchar(1000) as url,+ (audio_set ->> 'filesize') :: integer as filesize,+ (audio_set ->> 'filetype') :: varchar(80) as filetype,+ (audio_set ->> 'thumbnail') :: varchar(1000) as thumbnail,+ provider+ FROM public.{AUDIO_VIEW_NAME}+ WHERE audio_set IS NOT NULL;+ """ # noqa: E501+ )++def create_media_view(postgres_conn_id,media_type=IMAGE,@@ -338,6 +364,8 @@ def create_media_view()postgres.run(create_view_query)postgres.run(add_idx_query)+ if media_type == AUDIO:+ postgres.run(create_audioset_view_query())def update_db_view(