Revert "Reduce API response times by caching migration flag"

This reverts commit 5433af6716.
This commit is contained in:
AlanCoding
2020-01-02 09:08:51 -05:00
parent 1f46878652
commit 8d4425f056
3 changed files with 5 additions and 24 deletions

View File

@@ -18,7 +18,6 @@ from django.db import IntegrityError, connection
from django.utils.functional import curry
from django.shortcuts import get_object_or_404, redirect
from django.apps import apps
from django.core.cache import cache
from django.utils.deprecation import MiddlewareMixin
from django.utils.translation import ugettext_lazy as _
from django.urls import reverse, resolve
@@ -214,11 +213,8 @@ class URLModificationMiddleware(MiddlewareMixin):
class MigrationRanCheckMiddleware(MiddlewareMixin):
def process_request(self, request):
if cache.get('migration_in_progress', False):
executor = MigrationExecutor(connection)
plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
if not bool(plan):
logger.info('Detected that migration finished, migration page taken down.')
cache.delete('migration_in_progress')
elif getattr(resolve(request.path), 'url_name', '') != 'migrations_notran':
return redirect(reverse("ui:migrations_notran"))
executor = MigrationExecutor(connection)
plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
if bool(plan) and \
getattr(resolve(request.path), 'url_name', '') != 'migrations_notran':
return redirect(reverse("ui:migrations_notran"))