Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from rest_framework.response import Response
from rest_framework.renderers import JSONRenderer
from rest_framework_csv.renderers import CSVRenderer
from rest_framework_extensions.cache.decorators import cache_response
from rest_framework_extensions.key_constructor.constructors import DefaultListKeyConstructor
from api.pagination import LargePagination
from api.renderers import ZipRenderer
from rest_framework.viewsets import ModelViewSet
Expand Down Expand Up @@ -533,7 +531,6 @@ def create_dump(self, request, pk=None):
serializer = CompetitionCreationTaskStatusSerializer({"status": "Success. Competition dump is being created."})
return Response(serializer.data, status=201)

@cache_response(key_func=DefaultListKeyConstructor())
@action(detail=False, methods=('GET',), pagination_class=LargePagination)
def public(self, request):
qs = self.get_queryset()
Expand Down
24 changes: 9 additions & 15 deletions src/static/riot/competitions/public-list.tag
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<script>
var self = this
self.competitions = {}
self.competitions_cache = {}

self.one("mount", function () {
self.update_competitions_list(self.get_url_page_number_or_default())
Expand All @@ -68,26 +67,21 @@
// Function to handle successful data retrieval
function handleSuccess(response) {
self.competitions = response;
self.competitions_cache[self.current_page.toString()] = response;
$('#loading').hide(); // Hide the loading indicator
$('.pagination-nav').show(); // Show pagination navigation
history.pushState("", document.title, "?page=" + self.current_page);
$('.pagination-nav > button').prop('disabled', false);
self.update();
}
// Check if data is in cache
if (self.competitions_cache[self.current_page]) {
handleSuccess(self.competitions_cache[self.current_page]);
} else {
// Fetch data using AJAX call
return CODALAB.api.get_public_competitions({"page": self.current_page})
.fail(function (response) {
$('#loading').hide(); // Hide the loading indicator
$('.pagination-nav').show(); // Show pagination navigation
toastr.error("Could not load competition list");
})
.done(handleSuccess);
}
// Fetch data using AJAX call
return CODALAB.api.get_public_competitions({"page": self.current_page})
.fail(function (response) {
$('#loading').hide(); // Hide the loading indicator
$('.pagination-nav').show(); // Show pagination navigation
toastr.error("Could not load competition list");
})
.done(handleSuccess);

};


Expand Down