2022-06-03 08:09:47 -06:00
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
|
|
from common.custom_celery_tasks import shared_dedicated_queue_retry_task
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shared_dedicated_queue_retry_task(
|
|
|
|
|
autoretry_for=(Exception,), retry_backoff=True, max_retries=1 if settings.DEBUG else None
|
|
|
|
|
)
|
|
|
|
|
def wipe(alert_group_pk, user_pk):
|
2023-07-25 10:43:23 +01:00
|
|
|
from apps.alerts.models import AlertGroup
|
2023-10-05 14:32:40 +01:00
|
|
|
from apps.api.serializers.alert import AlertFieldsCacheSerializerMixin
|
|
|
|
|
from apps.api.serializers.alert_group import AlertGroupFieldsCacheSerializerMixin
|
2023-07-25 10:43:23 +01:00
|
|
|
from apps.user_management.models import User
|
|
|
|
|
|
2023-07-18 13:48:34 +02:00
|
|
|
alert_group = AlertGroup.objects.filter(pk=alert_group_pk).first()
|
2022-06-03 08:09:47 -06:00
|
|
|
user = User.objects.filter(pk=user_pk).first()
|
|
|
|
|
alert_group.wipe_by_user(user)
|
2023-10-05 14:32:40 +01:00
|
|
|
|
|
|
|
|
# Clear internal API cache
|
|
|
|
|
AlertGroupFieldsCacheSerializerMixin.bust_object_caches(alert_group)
|
|
|
|
|
for alert in alert_group.alerts.all():
|
|
|
|
|
AlertFieldsCacheSerializerMixin.bust_object_caches(alert)
|