Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Add audio_set_foreign_identifier to the audio materialized view (#565)
Olga Bulat49ed0dcf24a3
diff --git a/docker/local_postgres/0007_openledger_audio_view.sql b/docker/local_postgres/0007_openledger_audio_view.sqlindex 6aecbb524..e4a51f0c9 100644--- a/docker/local_postgres/0007_openledger_audio_view.sql+++ b/docker/local_postgres/0007_openledger_audio_view.sql@@ -79,6 +79,7 @@ CREATE MATERIALIZED VIEW audio_view ASwatermarked,last_synced_with_source,removed_from_source,+ audio_set ->> 'foreign_identifier' AS audio_set_foreign_identifier,standardized_audio_popularity(audio.provider, audio.meta_data) AS standardized_popularitydiff --git a/openverse_catalog/dags/common/popularity/sql.py b/openverse_catalog/dags/common/popularity/sql.pyindex 466a9ad14..c13c5c7da 100644--- a/openverse_catalog/dags/common/popularity/sql.py+++ b/openverse_catalog/dags/common/popularity/sql.py@@ -341,11 +341,14 @@ def create_media_view(db_view_provider_fid_idx = AUDIO_VIEW_PROVIDER_FID_IDXstandardized_popularity_func = STANDARDIZED_AUDIO_POPULARITY_FUNCTIONpostgres = PostgresHook(postgres_conn_id=postgres_conn_id)+ audio_set_id_str = (+ "\naudio_set ->> 'foreign_identifier' AS audio_set_foreign_identifier,"+ )create_view_query = dedent(f"""CREATE MATERIALIZED VIEW public.{db_view_name} ASSELECT- *,+ *,{audio_set_id_str if media_type == AUDIO else ""}{standardized_popularity_func}({table_name}.{PARTITION},{table_name}.{METADATA_COLUMN}