Skip to content

Commit

Permalink
documented function
Browse files Browse the repository at this point in the history
  • Loading branch information
lowtorola committed Nov 25, 2024
1 parent c379da3 commit adc383c
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
36 changes: 34 additions & 2 deletions backend/siarnaq/api/compete/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,40 @@ def get_top_historical_rating_ranking(self, episode_id, limit=None):
pagination_class=None,
)
def historical_rating(self, request, pk=None, *, episode_id):
"""List the historical ratings of a team."""
# TODO: document this code! :)
"""
Provides a list of historical ratings for a team in a given episode.
Supports filtering by team ID or defaults to the current user's team
if no team ID is provided.
Parameters:
- request (Request) - The HTTP request object.
- pk (int, optional) - The primary key of the object. Defaults to None.
- episode_id (int) - The ID of the episode to filter the ratings by.
Query Parameters:
- team_id (int, optional) - The team ID for which to retrieve
historical ratings. If not provided, defaults to the team of the
requesting user.
Returns:
Response: A JSON response containing:
- 200 OK: Returns a serialized representation of the team's
historical ratings if found.
- 204 No Content: If no ranked matches are found for the specified team.
- 400 Bad Request: If the specified team could not be found.
Raises:
- 400 Bad Request: If neither a valid team ID is provided nor can a team be
determined from the current user.
Permissions:
Requires `IsEpisodeMutable` permission class.
Notes:
- The function does not paginate results.
- The function returns an empty list if no valid team is found.
- Historical ratings are ordered by match creation date.
"""
team_id = self.request.query_params.get("team_id")

if team_id is not None:
Expand Down
34 changes: 33 additions & 1 deletion frontend2/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,39 @@ paths:
/api/compete/{episode_id}/match/historical_rating/:
get:
operationId: compete_match_historical_rating_retrieve
description: List the historical ratings of a team.
description: |-
Provides a list of historical ratings for a team in a given episode.
Supports filtering by team ID or defaults to the current user's team
if no team ID is provided.
Parameters:
- request (Request) - The HTTP request object.
- pk (int, optional) - The primary key of the object. Defaults to None.
- episode_id (int) - The ID of the episode to filter the ratings by.
Query Parameters:
- team_id (int, optional) - The team ID for which to retrieve
historical ratings. If not provided, defaults to the team of the
requesting user.
Returns:
Response: A JSON response containing:
- 200 OK: Returns a serialized representation of the team's
historical ratings if found.
- 204 No Content: If no ranked matches are found for the specified team.
- 400 Bad Request: If the specified team could not be found.
Raises:
- 400 Bad Request: If neither a valid team ID is provided nor can a team be
determined from the current user.
Permissions:
Requires `IsEpisodeMutable` permission class.
Notes:
- The function does not paginate results.
- The function returns an empty list if no valid team is found.
- Historical ratings are ordered by match creation date.
parameters:
- in: path
name: episode_id
Expand Down
8 changes: 7 additions & 1 deletion frontend2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ const router = createBrowserRouter([
children: [
{
element: <PrivateRoute />,
children: [{ path: "/account", element: <Account />, loader: accountLoader(queryClient) }],
children: [
{
path: "/account",
element: <Account />,
loader: accountLoader(queryClient),
},
],
},
{
path: "user/:userId",
Expand Down
4 changes: 2 additions & 2 deletions frontend2/src/api/_autogen/apis/CompeteApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export interface CompeteSubmissionTournamentListRequest {
export class CompeteApi extends runtime.BaseAPI {

/**
* List the historical ratings of a team.
* Provides a list of historical ratings for a team in a given episode. Supports filtering by team ID or defaults to the current user\'s team if no team ID is provided. Parameters: - request (Request) - The HTTP request object. - pk (int, optional) - The primary key of the object. Defaults to None. - episode_id (int) - The ID of the episode to filter the ratings by. Query Parameters: - team_id (int, optional) - The team ID for which to retrieve historical ratings. If not provided, defaults to the team of the requesting user. Returns: Response: A JSON response containing: - 200 OK: Returns a serialized representation of the team\'s historical ratings if found. - 204 No Content: If no ranked matches are found for the specified team. - 400 Bad Request: If the specified team could not be found. Raises: - 400 Bad Request: If neither a valid team ID is provided nor can a team be determined from the current user. Permissions: Requires `IsEpisodeMutable` permission class. Notes: - The function does not paginate results. - The function returns an empty list if no valid team is found. - Historical ratings are ordered by match creation date.
*/
async competeMatchHistoricalRatingRetrieveRaw(requestParameters: CompeteMatchHistoricalRatingRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<HistoricalRating>> {
if (requestParameters.episodeId === null || requestParameters.episodeId === undefined) {
Expand Down Expand Up @@ -217,7 +217,7 @@ export class CompeteApi extends runtime.BaseAPI {
}

/**
* List the historical ratings of a team.
* Provides a list of historical ratings for a team in a given episode. Supports filtering by team ID or defaults to the current user\'s team if no team ID is provided. Parameters: - request (Request) - The HTTP request object. - pk (int, optional) - The primary key of the object. Defaults to None. - episode_id (int) - The ID of the episode to filter the ratings by. Query Parameters: - team_id (int, optional) - The team ID for which to retrieve historical ratings. If not provided, defaults to the team of the requesting user. Returns: Response: A JSON response containing: - 200 OK: Returns a serialized representation of the team\'s historical ratings if found. - 204 No Content: If no ranked matches are found for the specified team. - 400 Bad Request: If the specified team could not be found. Raises: - 400 Bad Request: If neither a valid team ID is provided nor can a team be determined from the current user. Permissions: Requires `IsEpisodeMutable` permission class. Notes: - The function does not paginate results. - The function returns an empty list if no valid team is found. - Historical ratings are ordered by match creation date.
*/
async competeMatchHistoricalRatingRetrieve(requestParameters: CompeteMatchHistoricalRatingRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<HistoricalRating> {
const response = await this.competeMatchHistoricalRatingRetrieveRaw(requestParameters, initOverrides);
Expand Down

0 comments on commit adc383c

Please sign in to comment.