# Which issue(s) this PR fixes - Fix issue that was causing our openapi schema to return HTTP 500 + add an integration test which fetches the `.yaml` schema and validates that the endpoint returns HTTP 200 (should hopefully prevent this from happening again). - add a few more type hints along the way ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
16 lines
557 B
Python
16 lines
557 B
Python
import typing
|
|
|
|
from django.core.cache import cache
|
|
|
|
|
|
class AlertsFieldCacheBusterMixin:
|
|
RENDER_FOR_WEB_FIELD_NAME = "render_for_web"
|
|
ALL_FIELD_NAMES = [RENDER_FOR_WEB_FIELD_NAME]
|
|
|
|
@classmethod
|
|
def calculate_cache_key(cls, field_name: str, obj: typing.Any) -> str:
|
|
return cls.CACHE_KEY_FORMAT_TEMPLATE.format(field_name=field_name, object_id=obj.id)
|
|
|
|
@classmethod
|
|
def bust_object_caches(cls, obj: typing.Any) -> None:
|
|
cache.delete_many([cls.calculate_cache_key(field_name, obj) for field_name in cls.ALL_FIELD_NAMES])
|