Skip to content

Commit

Permalink
BugFix: Add order_by request data in leaderboard API call
Browse files Browse the repository at this point in the history
  • Loading branch information
Ram81 committed Aug 22, 2021
1 parent f06dd45 commit b9566a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions apps/jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def leaderboard(request, challenge_phase_split_id):


@swagger_auto_schema(
methods=["get"],
methods=["get", "post"],
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"])
@api_view(["GET", "POST"])
@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")
(
response_data,
http_status_code,
Expand All @@ -803,6 +803,7 @@ def get_all_entries_on_public_leaderboard(request, challenge_phase_split_pk):
challenge_obj,
challenge_phase_split,
only_public_entries=False,
order_by=order_by,
)
# The response 400 will be returned if the leaderboard isn't public or `default_order_by` key is missing in leaderboard.
if http_status_code == status.HTTP_400_BAD_REQUEST:
Expand Down Expand Up @@ -2335,6 +2336,7 @@ def get_github_badge_data(
challenge_obj,
challenge_phase_split,
only_public_entries=True,
order_by=None,
)
if http_status_code == status.HTTP_400_BAD_REQUEST:
return Response(response_data, status=http_status_code)
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/js/controllers/challengeCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1461,8 +1461,10 @@
// Show leaderboard
vm.leaderboard = {};
parameters.url = "jobs/" + "phase_split/" + vm.phaseSplitId + "/public_leaderboard_all_entries/?page_size=1000";
parameters.method = 'GET';
parameters.data = {};
parameters.method = 'POST';
parameters.data = {
"order_by": vm.orderLeaderboardBy
};
parameters.callback = {
onSuccess: function(response) {
var details = response.data;
Expand Down

0 comments on commit b9566a7

Please sign in to comment.