openverse icon indicating copy to clipboard operation
openverse copied to clipboard

Exclude media from sources without `ContentProvider` record from search

Open obulat opened this issue 10 months ago • 1 comments

Problem

When we add a new provider, we don't immediately add a ContentProvider record to the API. This means that the media is immediately available in search results.

Description

When building an excluded source query, we should add the sources that don't have a ContentProvider model to the excluded sources. To do that, we can get all sources using:

https://github.com/WordPress/openverse/blob/d377c69fa360c9e32ec74272cd0d69f8ff8fe04c/api/api/controllers/search_controller.py#L549

This is where the query is built:

https://github.com/WordPress/openverse/blob/d377c69fa360c9e32ec74272cd0d69f8ff8fe04c/api/api/controllers/search_controller.py#L188-L193

Alternatives

An alternative would be to add a step to the data refresh that would add new ContentProvider records for all the sources that were added during the data refresh: #3548

Additional context

#2487 is related in that it added a filter for the single results: if "Hide content" for their provider is set to True, the result is not returned.

obulat avatar Apr 09 '24 03:04 obulat