diff --git a/src/athletes/athlete.query.ts b/src/athletes/athlete.query.ts index 4915ec3..f82c6d9 100644 --- a/src/athletes/athlete.query.ts +++ b/src/athletes/athlete.query.ts @@ -17,7 +17,6 @@ const ATHLETE_QUERY = gql` date mark venue - indoor notLegal resultScore wind @@ -32,7 +31,6 @@ const ATHLETE_QUERY = gql` date mark venue - indoor notLegal resultScore wind @@ -52,7 +50,6 @@ const ATHLETE_QUERY = gql` honours { results { place - indoor disciplineCode discipline competition diff --git a/src/athletes/athlete.zod.ts b/src/athletes/athlete.zod.ts index 1c435d3..f701e2b 100644 --- a/src/athletes/athlete.zod.ts +++ b/src/athletes/athlete.zod.ts @@ -29,10 +29,8 @@ const Performance = z.object({ return date; }), discipline: z.string(), - disciplineCode: z.string().nullable(), mark: z.string(), venue: z.string(), - indoor: z.boolean(), notLegal: z.boolean(), resultScore: z.number(), wind: z @@ -59,10 +57,8 @@ const Result = z.object({ return date; }), discipline: z.string(), - disciplineCode: z.string().nullable(), mark: z.string(), venue: z.string(), - indoor: z.boolean().nullable().default(false), competition: z.string(), place: z.preprocess((val) => { return Number(val); diff --git a/src/athletes/athletes.service.ts b/src/athletes/athletes.service.ts index 0b5c17d..5349621 100644 --- a/src/athletes/athletes.service.ts +++ b/src/athletes/athletes.service.ts @@ -76,15 +76,16 @@ export class AthletesService { }) .map((result) => { const location = parseVenue(result.venue); + const indoor = result.venue.endsWith('(i)'); + result.venue = result.venue.replace(' (i)', ''); return { date: result.date, discipline: result.discipline, - disciplineCode: - result.disciplineCode || mapDisciplineToCode(result.discipline), + disciplineCode: mapDisciplineToCode(result.discipline), mark: result.mark.replace(/[^0-9:.]/g, ''), venue: result.venue, location, - indoor: result.indoor, + indoor, legal: !result.notLegal, resultScore: result.resultScore, wind: result.wind, @@ -98,14 +99,16 @@ export class AthletesService { personalbests: response.getSingleCompetitor.personalBests.results.map( (result) => { const location = parseVenue(result.venue); + const indoor = result.venue.endsWith('(i)'); + result.venue = result.venue.replace(' (i)', ''); return { date: result.date, discipline: result.discipline, - disciplineCode: result.disciplineCode, + disciplineCode: mapDisciplineToCode(result.discipline), mark: result.mark.replace(/[^0-9:.]/g, ''), venue: result.venue, location, - indoor: result.indoor, + indoor, legal: !result.notLegal, resultScore: result.resultScore, wind: result.wind, @@ -121,14 +124,16 @@ export class AthletesService { return { category: honour.categoryName, results: honour.results.map((result) => { + const indoor = result.venue.endsWith('(i)'); + result.venue = result.venue.replace(' (i)', ''); return { date: result.date, discipline: result.discipline, - disciplineCode: result.disciplineCode, + disciplineCode: mapDisciplineToCode(result.discipline), mark: result.mark.replace(/[^0-9:.]/g, ''), venue: result.venue, location: parseVenue(result.venue), - indoor: result.indoor, + indoor, competition: result.competition, place: result.place, resultScore: 0, diff --git a/src/athletes/results/result.query.ts b/src/athletes/results/result.query.ts index cd135ca..a28df9a 100644 --- a/src/athletes/results/result.query.ts +++ b/src/athletes/results/result.query.ts @@ -10,7 +10,6 @@ const RESULTS_QUERY = gql` resultsByEvent { disciplineCode discipline - indoor results { mark competition diff --git a/src/athletes/results/result.service.ts b/src/athletes/results/result.service.ts index 87cc9c6..701d016 100644 --- a/src/athletes/results/result.service.ts +++ b/src/athletes/results/result.service.ts @@ -5,6 +5,7 @@ import RESULTS_QUERY from './result.query'; import { ResultsByEvent } from './result.zod'; import { Performance } from '../athlete.dto'; import parseVenue from '../venue.utils'; +import mapDisciplineToCode from 'src/discipline.utils'; @Injectable() export class ResultsService { @@ -39,10 +40,11 @@ export class ResultsService { const results: Performance[] = []; response.getSingleCompetitorResultsDiscipline.resultsByEvent.forEach( (event) => { - const indoor = event.indoor; const discipline = event.discipline; - const disciplineCode = event.disciplineCode; + const disciplineCode = mapDisciplineToCode(discipline); event.results.forEach((result) => { + const indoor = result.competition.endsWith('(i)'); + result.competition = result.competition.replace(' (i)', ''); results.push({ category: result.category, competition: result.competition, diff --git a/src/athletes/results/result.zod.ts b/src/athletes/results/result.zod.ts index 885cee8..9ce3cf6 100644 --- a/src/athletes/results/result.zod.ts +++ b/src/athletes/results/result.zod.ts @@ -3,9 +3,7 @@ import { z } from 'zod'; export const ResultsByEvent = z.object({ resultsByEvent: z.array( z.object({ - disciplineCode: z.string().nullable(), discipline: z.string(), - indoor: z.boolean().nullable().default(false), results: z.array( z.object({ mark: z.string(),