Commit 59d37de2 authored by Giannis Tsapelas's avatar Giannis Tsapelas
Browse files

disable api caching

parent cc8ac8a4
......@@ -4,6 +4,7 @@ from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import never_cache
from query_designer.models import *
from django.http import JsonResponse
......@@ -16,10 +17,12 @@ import traceback
@login_required
@never_cache
def execute_query(request, pk=None):
user = request.user
if request.method == 'GET':
limit = int(request.GET.get('limit', '10000'))
try:
q = AbstractQuery.objects.get(pk=pk)
if q.user != user:
......@@ -28,13 +31,15 @@ def execute_query(request, pk=None):
return HttpResponse('Query not found', status=404)
if request.method == 'POST':
limit = int(request.POST.get('limit', '10000'))
try:
doc_str = request.POST.get('query')
q = AbstractQuery(document=json.loads(doc_str))
except:
return HttpResponse('Bad Request', status=400)
q.document['limit'] = 1000000
q.document['limit'] = limit
# get POST params
dimension_values = request.POST.get('dimension_values', '')
......@@ -71,7 +76,7 @@ def execute_query(request, pk=None):
if e.args[0] == 'max_memory_exceeded':
return JsonResponse({"error_message": 'Your query execution exceeded the available memory. Please limit your selection on space and time and try again.'})
else:
return JsonResponse({"error_message": str(e.message)})
return JsonResponse({"error_message": ''})
response, encoder = result
# import pdb
# pdb.set_trace()
......
......@@ -13,6 +13,7 @@ from datetime import datetime, timedelta
import time
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.views.decorators.cache import never_cache
def index(request):
return render(request, 'query_designer/index.html', {
......@@ -20,6 +21,7 @@ def index(request):
})
@login_required
@never_cache
def load_query(request, pk):
q = Query.objects.get(pk=pk)
......@@ -205,6 +207,7 @@ def save_query(request, pk=None, temp=1):
@login_required
@never_cache
def get_query_variables(request):
if 'id' in request.GET:
id = int(request.GET.get('id'))
......@@ -344,6 +347,7 @@ def get_config(request):
@login_required
@never_cache
def list_queries(request):
user = request.user if request.user.is_authenticated else None
......@@ -377,6 +381,7 @@ def delete_query(request, pk):
@login_required
@never_cache
def api_list_user_queries(request):
if request.user.is_authenticated:
user = request.user
......@@ -388,6 +393,7 @@ def api_list_user_queries(request):
@login_required
@never_cache
def get_query_statement(request, query_id):
# ensure GET request
if request.method != 'GET':
......@@ -404,6 +410,7 @@ def get_query_statement(request, query_id):
@login_required
@never_cache
def get_query_info(request, query_id):
# ensure GET request
if request.method != 'GET':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment