Skip to content

Commit

Permalink
implemented win loss tie
Browse files Browse the repository at this point in the history
  • Loading branch information
lowtorola committed May 13, 2024
1 parent 4a78925 commit 03e406c
Show file tree
Hide file tree
Showing 20 changed files with 636 additions and 33 deletions.
57 changes: 56 additions & 1 deletion frontend2/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ paths:
type: array
items:
type: integer
description: A list of teams to filter for. Defaults to just your own team.
description: A list of teams to filter for. Defaults to your own team.
tags:
- compete
security:
Expand Down Expand Up @@ -207,6 +207,45 @@ paths:
schema:
$ref: '#/components/schemas/PaginatedMatchList'
description: ''
/api/compete/{episode_id}/match/scrimmaging_record/:
get:
operationId: compete_match_scrimmaging_record_retrieve
description: List the scrimmaging win-loss-tie record of a team.
parameters:
- in: path
name: episode_id
schema:
type: string
pattern: ^[^\/.]+$
required: true
- in: query
name: scrimmage_type
schema:
type: string
enum:
- all
- ranked
- unranked
default: all
description: Which type of scrimmages to filter for. Defaults to all.
- in: query
name: team_id
schema:
type: integer
description: A team to filter for. Defaults to your own team.
tags:
- compete
security:
- jwtAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ScrimmageRecord'
description: ''
'400':
description: No team found with the given ID.
/api/compete/{episode_id}/match/tournament/:
get:
operationId: compete_match_tournament_list
Expand Down Expand Up @@ -2563,6 +2602,22 @@ components:
type: boolean
required:
- status
ScrimmageRecord:
type: object
properties:
team_id:
type: integer
wins:
type: integer
losses:
type: integer
ties:
type: integer
required:
- losses
- team_id
- ties
- wins
ScrimmageRequest:
type: object
properties:
Expand Down
12 changes: 10 additions & 2 deletions frontend2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { tournamentsLoader } from "./api/loaders/tournamentsLoader";
import { tournamentLoader } from "./api/loaders/tournamentLoader";
import { homeLoader } from "./api/loaders/homeLoader";
import ErrorBoundary from "./views/ErrorBoundary";
import { searchTeamsFactory } from "api/team/teamFactories";
import { myTeamFactory, searchTeamsFactory } from "api/team/teamFactories";
import PageNotFound from "views/PageNotFound";

const queryClient = new QueryClient({
Expand All @@ -70,7 +70,7 @@ queryClient.setQueryDefaults(["team"], { retry: false });
queryClient.setQueryDefaults(["user"], { retry: false });

// Run a check to see if the user has an invalid token
await loginCheck(queryClient);
const loggedIn = await loginCheck(queryClient);

const App: React.FC = () => {
return (
Expand Down Expand Up @@ -117,6 +117,14 @@ const episodeLoader: LoaderFunction = async ({ params }) => {
),
});

// Prefetch the user's team.
if (loggedIn) {
void queryClient.ensureQueryData({
queryKey: buildKey(myTeamFactory.queryKey, { episodeId: id }),
queryFn: async () => await myTeamFactory.queryFn({ episodeId: id }),
});
}

return episodeInfo;
};

Expand Down
1 change: 1 addition & 0 deletions frontend2/src/api/_autogen/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ models/ReleaseStatusEnum.ts
models/ResetToken.ts
models/ResetTokenRequest.ts
models/SaturnInvocationRequest.ts
models/ScrimmageRecord.ts
models/ScrimmageRequest.ts
models/ScrimmageRequestRequest.ts
models/ScrimmageStatusEnum.ts
Expand Down
65 changes: 65 additions & 0 deletions frontend2/src/api/_autogen/apis/CompeteApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
PaginatedMatchList,
PaginatedScrimmageRequestList,
PaginatedSubmissionList,
ScrimmageRecord,
ScrimmageRequest,
ScrimmageRequestRequest,
Submission,
Expand All @@ -41,6 +42,8 @@ import {
PaginatedScrimmageRequestListToJSON,
PaginatedSubmissionListFromJSON,
PaginatedSubmissionListToJSON,
ScrimmageRecordFromJSON,
ScrimmageRecordToJSON,
ScrimmageRequestFromJSON,
ScrimmageRequestToJSON,
ScrimmageRequestRequestFromJSON,
Expand Down Expand Up @@ -92,6 +95,12 @@ export interface CompeteMatchScrimmageListRequest {
teamId?: number;
}

export interface CompeteMatchScrimmagingRecordRetrieveRequest {
episodeId: string;
scrimmageType?: CompeteMatchScrimmagingRecordRetrieveScrimmageTypeEnum;
teamId?: number;
}

export interface CompeteMatchTournamentListRequest {
episodeId: string;
externalIdPrivate?: string;
Expand Down Expand Up @@ -470,6 +479,52 @@ export class CompeteApi extends runtime.BaseAPI {
return await response.value();
}

/**
* List the scrimmaging win-loss-tie record of a team.
*/
async competeMatchScrimmagingRecordRetrieveRaw(requestParameters: CompeteMatchScrimmagingRecordRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ScrimmageRecord>> {
if (requestParameters.episodeId === null || requestParameters.episodeId === undefined) {
throw new runtime.RequiredError('episodeId','Required parameter requestParameters.episodeId was null or undefined when calling competeMatchScrimmagingRecordRetrieve.');
}

const queryParameters: any = {};

if (requestParameters.scrimmageType !== undefined) {
queryParameters['scrimmage_type'] = requestParameters.scrimmageType;
}

if (requestParameters.teamId !== undefined) {
queryParameters['team_id'] = requestParameters.teamId;
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("jwtAuth", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/api/compete/{episode_id}/match/scrimmaging_record/`.replace(`{${"episode_id"}}`, encodeURIComponent(String(requestParameters.episodeId))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ScrimmageRecordFromJSON(jsonValue));
}

/**
* List the scrimmaging win-loss-tie record of a team.
*/
async competeMatchScrimmagingRecordRetrieve(requestParameters: CompeteMatchScrimmagingRecordRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ScrimmageRecord> {
const response = await this.competeMatchScrimmagingRecordRetrieveRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* List matches played in a tournament, or in all tournaments if not specified. Passing the external_id_private of a tournament allows match lookup for the tournament, even if it\'s private. Client uses the external_id_private parameter
*/
Expand Down Expand Up @@ -1060,3 +1115,13 @@ export class CompeteApi extends runtime.BaseAPI {
}

}

/**
* @export
* @enum {string}
*/
export enum CompeteMatchScrimmagingRecordRetrieveScrimmageTypeEnum {
All = 'all',
Ranked = 'ranked',
Unranked = 'unranked'
}
93 changes: 93 additions & 0 deletions frontend2/src/api/_autogen/models/ScrimmageRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
/**
*
* @export
* @interface ScrimmageRecord
*/
export interface ScrimmageRecord {
/**
*
* @type {number}
* @memberof ScrimmageRecord
*/
team_id: number;
/**
*
* @type {number}
* @memberof ScrimmageRecord
*/
wins: number;
/**
*
* @type {number}
* @memberof ScrimmageRecord
*/
losses: number;
/**
*
* @type {number}
* @memberof ScrimmageRecord
*/
ties: number;
}

/**
* Check if a given object implements the ScrimmageRecord interface.
*/
export function instanceOfScrimmageRecord(value: object): boolean {
let isInstance = true;
isInstance = isInstance && "team_id" in value;
isInstance = isInstance && "wins" in value;
isInstance = isInstance && "losses" in value;
isInstance = isInstance && "ties" in value;

return isInstance;
}

export function ScrimmageRecordFromJSON(json: any): ScrimmageRecord {
return ScrimmageRecordFromJSONTyped(json, false);
}

export function ScrimmageRecordFromJSONTyped(json: any, ignoreDiscriminator: boolean): ScrimmageRecord {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'team_id': json['team_id'],
'wins': json['wins'],
'losses': json['losses'],
'ties': json['ties'],
};
}

export function ScrimmageRecordToJSON(value?: ScrimmageRecord | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'team_id': value.team_id,
'wins': value.wins,
'losses': value.losses,
'ties': value.ties,
};
}

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function UserProfilePrivateRequestFromJSONTyped(json: any, ignoreDiscrimi
return json;
}
return {

'gender': GenderEnumFromJSON(json['gender']),
'gender_details': !exists(json, 'gender_details') ? undefined : json['gender_details'],
'school': !exists(json, 'school') ? undefined : json['school'],
Expand All @@ -108,7 +108,7 @@ export function UserProfilePrivateRequestToJSON(value?: UserProfilePrivateReques
return null;
}
return {

'gender': GenderEnumToJSON(value.gender),
'gender_details': value.gender_details,
'school': value.school,
Expand Down
1 change: 1 addition & 0 deletions frontend2/src/api/_autogen/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export * from './ReleaseStatusEnum';
export * from './ResetToken';
export * from './ResetTokenRequest';
export * from './SaturnInvocationRequest';
export * from './ScrimmageRecord';
export * from './ScrimmageRequest';
export * from './ScrimmageRequestRequest';
export * from './ScrimmageStatusEnum';
Expand Down
20 changes: 20 additions & 0 deletions frontend2/src/api/compete/competeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
type CompeteRequestDestroyRequest,
type CompeteMatchHistoricalRatingListRequest,
type HistoricalRating,
type CompeteMatchScrimmagingRecordRetrieveRequest,
type ScrimmageRecord,
} from "../_autogen";
import { DEFAULT_API_CONFIGURATION, downloadFile } from "../helpers";

Expand Down Expand Up @@ -224,3 +226,21 @@ export const getRatingList = async ({
teamIds,
}: CompeteMatchHistoricalRatingListRequest): Promise<HistoricalRating[]> =>
await API.competeMatchHistoricalRatingList({ episodeId, teamIds });

/**
* Get a team's win-loss-tie record in scrimmages in a given episode. Defaults to the logged in user's team.
* Defaults to all scrimmage types.
* @param episodeId The episode ID to retrieve record data for.
* @param teamId The team ID to retrieve record data for.
* @param scrimmageType The type of scrimmage to retrieve record data for.
*/
export const getScrimmagingRecord = async ({
episodeId,
teamId,
scrimmageType,
}: CompeteMatchScrimmagingRecordRetrieveRequest): Promise<ScrimmageRecord> =>
await API.competeMatchScrimmagingRecordRetrieve({
episodeId,
teamId,
scrimmageType,
});
Loading

0 comments on commit 03e406c

Please sign in to comment.