WordPress / openverse

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
https://openverse.org
MIT License
215 stars 177 forks source link

Remove transition code in search controller #706

Open dhruvkb opened 2 years ago

dhruvkb commented 2 years ago

Problem

The code described in this snippet was transitionary and has served its utility. It should be removed.

https://github.com/WordPress/openverse/blob/7e558ef6a03de677895c17f2125a717632df839c/api/api/controllers/search_controller.py#L552-L569

Description

This cache invalidation snippet has definitely run in production and the caches have surely been migrated to the new format. This should no longer be a part of the codebase.

Alternatives

Even in the highly unlikely event that the caches have not been cleared and updated, a better solution would be to use try...except to handle invalid values rather than using a very specific transition state.

Additional context

The issue originally pointed to this code snippet from the now-deprecated and archived WordPress/openverse-api repo https://github.com/WordPress/openverse-api/blob/6cc0551c639081f895d974b30cc465713d0ce360/api/catalog/api/controllers/search_controller.py#L379-L387

Implementation

sarayourfriend commented 2 years ago

Can we check the production cache to confirm this is safe?

dhruvkb commented 2 years ago

@sarayourfriend given how long this has existed in the code, it's safe to assume this code has executed at least once, but yeah we can check the cache once and verify.

sarayourfriend commented 1 month ago

@dhruvkb can you update this issue with a new link for the monorepo code? At a glance, I think I understand what would need to be removed, but the issue is old enough and the link is to the archive repo, so my confidence that I can understand it is low (which doesn't bode well for many other people outside the team :sweat_smile:).

dhruvkb commented 1 month ago

@sarayourfriend, done.