Skip to content

Commit

Permalink
check if venue is indoor by title
Browse files Browse the repository at this point in the history
  • Loading branch information
nimarion committed Dec 22, 2023
1 parent fe78d34 commit 07d900e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
3 changes: 0 additions & 3 deletions src/athletes/athlete.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const ATHLETE_QUERY = gql`
date
mark
venue
indoor
notLegal
resultScore
wind
Expand All @@ -32,7 +31,6 @@ const ATHLETE_QUERY = gql`
date
mark
venue
indoor
notLegal
resultScore
wind
Expand All @@ -52,7 +50,6 @@ const ATHLETE_QUERY = gql`
honours {
results {
place
indoor
disciplineCode
discipline
competition
Expand Down
4 changes: 0 additions & 4 deletions src/athletes/athlete.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
19 changes: 12 additions & 7 deletions src/athletes/athletes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/athletes/results/result.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const RESULTS_QUERY = gql`
resultsByEvent {
disciplineCode
discipline
indoor
results {
mark
competition
Expand Down
6 changes: 4 additions & 2 deletions src/athletes/results/result.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/athletes/results/result.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 07d900e

Please sign in to comment.