Skip to content

Commit

Permalink
Backend+Frontend: Fetch public leaderboard when user is not authentic…
Browse files Browse the repository at this point in the history
…ated(Cloud-CV#3590)
  • Loading branch information
Ram81 authored Sep 3, 2021
1 parent 9cb0dcd commit c40ccb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
12 changes: 6 additions & 6 deletions apps/jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def change_submission_data_and_visibility(


@swagger_auto_schema(
methods=["get", "post"],
methods=["get"],
manual_parameters=[
openapi.Parameter(
name="challenge_phase_split_id",
Expand Down Expand Up @@ -563,7 +563,7 @@ def change_submission_data_and_visibility(
)
},
)
@api_view(["GET", "POST"])
@api_view(["GET"])
@throttle_classes([AnonRateThrottle])
def leaderboard(request, challenge_phase_split_id):
"""
Expand All @@ -581,7 +581,7 @@ def leaderboard(request, challenge_phase_split_id):
challenge_phase_split_id
)
challenge_obj = challenge_phase_split.challenge_phase.challenge
order_by = request.data.get("order_by")
order_by = request.GET.get("order_by")
(
response_data,
http_status_code,
Expand All @@ -604,7 +604,7 @@ def leaderboard(request, challenge_phase_split_id):


@swagger_auto_schema(
methods=["get", "post"],
methods=["get"],
manual_parameters=[
openapi.Parameter(
name="challenge_phase_split_pk",
Expand Down Expand Up @@ -730,7 +730,7 @@ def leaderboard(request, challenge_phase_split_id):
),
},
)
@api_view(["GET", "POST"])
@api_view(["GET"])
@throttle_classes([AnonRateThrottle])
@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
@authentication_classes((JWTAuthentication, ExpiringTokenAuthentication))
Expand Down Expand Up @@ -794,7 +794,7 @@ def get_all_entries_on_public_leaderboard(request, challenge_phase_split_pk):
"error": "Sorry, you are not authorized to make this request!"
}
return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
order_by = request.data.get("order_by")
order_by = request.GET.get("order_by")
(
response_data,
http_status_code,
Expand Down
28 changes: 8 additions & 20 deletions frontend/src/js/controllers/challengeCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,8 @@
vm.startLeaderboard = function() {
vm.stopLeaderboard();
vm.poller = $interval(function() {
parameters.url = "jobs/" + "challenge_phase_split/" + vm.phaseSplitId + "/leaderboard/?page_size=1000";
parameters.method = 'POST';
parameters.data = {
"order_by": vm.orderLeaderboardBy
};
parameters.url = "jobs/" + "challenge_phase_split/" + vm.phaseSplitId + "/leaderboard/?page_size=1000&order_by=" + vm.orderLeaderboardBy;
parameters.method = 'GET';
parameters.callback = {
onSuccess: function(response) {
var details = response.data;
Expand Down Expand Up @@ -973,11 +970,8 @@

// Show leaderboard
vm.leaderboard = {};
parameters.url = "jobs/" + "challenge_phase_split/" + vm.phaseSplitId + "/leaderboard/?page_size=1000";
parameters.method = 'POST';
parameters.data = {
"order_by": vm.orderLeaderboardBy
};
parameters.url = "jobs/" + "challenge_phase_split/" + vm.phaseSplitId + "/leaderboard/?page_size=1000&order_by=" + vm.orderLeaderboardBy;
parameters.method = 'GET';
parameters.callback = {
onSuccess: function(response) {
var details = response.data;
Expand Down Expand Up @@ -1397,11 +1391,8 @@
vm.refreshLeaderboard = function() {
vm.startLoader("Loading Leaderboard Items");
vm.leaderboard = {};
parameters.url = "jobs/" + "challenge_phase_split/" + vm.phaseSplitId + "/leaderboard/?page_size=1000";
parameters.method = 'POST';
parameters.data = {
"order_by": vm.orderLeaderboardBy
};
parameters.url = "jobs/" + "challenge_phase_split/" + vm.phaseSplitId + "/leaderboard/?page_size=1000&order_by=" + vm.orderLeaderboardBy;
parameters.method = 'GET';
parameters.callback = {
onSuccess: function(response) {
var details = response.data;
Expand Down Expand Up @@ -1460,11 +1451,8 @@

// Show leaderboard
vm.leaderboard = {};
parameters.url = "jobs/" + "phase_split/" + vm.phaseSplitId + "/public_leaderboard_all_entries/?page_size=1000";
parameters.method = 'POST';
parameters.data = {
"order_by": vm.orderLeaderboardBy
};
parameters.url = "jobs/" + "phase_split/" + vm.phaseSplitId + "/public_leaderboard_all_entries/?page_size=1000&order_by=" + vm.orderLeaderboardBy;
parameters.method = 'GET';
parameters.callback = {
onSuccess: function(response) {
var details = response.data;
Expand Down

0 comments on commit c40ccb3

Please sign in to comment.