Skip to content

Commit

Permalink
Merge pull request #219 from EHDEN/hot_fix/refresh_matviews_after_db_…
Browse files Browse the repository at this point in the history
…udpate

Refresh matviews after datasource update
  • Loading branch information
joaorafaelalmeida authored Jan 10, 2022
2 parents 0465a11 + 24a93ca commit ec86db3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dashboard_viewer/uploader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

from materialized_queries_manager.tasks import refresh_materialized_views_task
from materialized_queries_manager.models import MaterializedQuery
from .decorators import uploader_decorator
from .forms import AchillesResultsForm, EditSourceForm, SourceForm
from .models import Country, DataSource, PendingUpload, UploadHistory
Expand Down Expand Up @@ -305,6 +307,8 @@ def partial_update(self, request, *_, **__):
serializer.is_valid(raise_exception=True)
serializer.save()

refresh_materialized_views_task.delay([obj.matviewname for obj in MaterializedQuery.objects.all()])

if getattr(instance, "_prefetched_objects_cache", None):
# If 'prefetch_related' has been applied to a queryset, we need to
# forcibly invalidate the prefetch cache on the instance.
Expand Down

0 comments on commit ec86db3

Please sign in to comment.