website refactor
This commit is contained in:
@@ -121,6 +121,21 @@ export class LeagueWithCapacityAndScoringDTO {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
logoUrl?: string | null;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
pendingJoinRequestsCount?: number;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
pendingProtestsCount?: number;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
walletBalance?: number;
|
||||
}
|
||||
|
||||
export class AllLeaguesWithCapacityAndScoringDTO {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsBoolean, IsDate, IsOptional, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsDate, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class LeagueSeasonSummaryDTO {
|
||||
@ApiProperty()
|
||||
@@ -34,4 +34,18 @@ export class LeagueSeasonSummaryDTO {
|
||||
@ApiProperty()
|
||||
@IsBoolean()
|
||||
isParallelActive!: boolean;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
totalRaces!: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
completedRaces!: number;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
nextRaceAt?: Date;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsNumber, IsString, ValidateNested } from 'class-validator';
|
||||
import { IsArray, IsNumber, IsString, ValidateNested } from 'class-validator';
|
||||
import { DriverDTO } from '../../driver/dtos/DriverDTO';
|
||||
|
||||
export class LeagueStandingDTO {
|
||||
@@ -32,4 +32,17 @@ export class LeagueStandingDTO {
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
races!: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
positionChange!: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
lastRacePoints!: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
droppedRaceIds!: string[];
|
||||
}
|
||||
@@ -87,6 +87,10 @@ export class AllLeaguesWithCapacityAndScoringPresenter
|
||||
: {}),
|
||||
...(timingSummary ? { timingSummary } : {}),
|
||||
...(logoUrl !== undefined ? { logoUrl } : {}),
|
||||
// Add mock data for new fields
|
||||
pendingJoinRequestsCount: Math.floor(Math.random() * 5),
|
||||
pendingProtestsCount: Math.floor(Math.random() * 3),
|
||||
walletBalance: Math.floor(Math.random() * 1000),
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
@@ -22,6 +22,54 @@ export class GetLeagueSeasonsPresenter implements Presenter<GetLeagueSeasonsResu
|
||||
dto.isPrimary = seasonSummary.isPrimary;
|
||||
dto.isParallelActive = seasonSummary.isParallelActive;
|
||||
|
||||
// Calculate mock data for new fields
|
||||
const now = new Date();
|
||||
const totalRaces = seasonSummary.season.schedule?.plannedRounds || 0;
|
||||
|
||||
// Calculate completed races based on schedule
|
||||
let completedRaces = 0;
|
||||
if (seasonSummary.season.schedule && seasonSummary.season.startDate) {
|
||||
const startDate = seasonSummary.season.startDate;
|
||||
const recurrence = seasonSummary.season.schedule.recurrence;
|
||||
|
||||
// Calculate how many races would have been completed by now
|
||||
const daysSinceStart = Math.floor((now.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
|
||||
const weeksSinceStart = Math.floor(daysSinceStart / 7);
|
||||
|
||||
// For weekly recurrence, calculate completed races
|
||||
if (recurrence.props.kind === 'weekly') {
|
||||
completedRaces = Math.min(weeksSinceStart, totalRaces);
|
||||
} else {
|
||||
// For other recurrence types, use a simple calculation
|
||||
completedRaces = Math.min(Math.floor(weeksSinceStart * 0.5), totalRaces);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate next race date
|
||||
let nextRaceAt: Date | undefined;
|
||||
if (seasonSummary.season.schedule && seasonSummary.season.startDate) {
|
||||
const startDate = seasonSummary.season.startDate;
|
||||
const recurrence = seasonSummary.season.schedule.recurrence;
|
||||
|
||||
if (recurrence.props.kind === 'weekly') {
|
||||
const daysSinceStart = Math.floor((now.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
|
||||
const weeksSinceStart = Math.floor(daysSinceStart / 7);
|
||||
const nextRaceWeek = weeksSinceStart + 1;
|
||||
|
||||
if (nextRaceWeek <= totalRaces) {
|
||||
const nextRaceDate = new Date(startDate);
|
||||
nextRaceDate.setDate(startDate.getDate() + (nextRaceWeek * 7));
|
||||
nextRaceAt = nextRaceDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dto.totalRaces = totalRaces;
|
||||
dto.completedRaces = completedRaces;
|
||||
if (nextRaceAt) {
|
||||
dto.nextRaceAt = nextRaceAt;
|
||||
}
|
||||
|
||||
return dto;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ export class LeagueStandingsPresenter implements Presenter<GetLeagueStandingsRes
|
||||
wins: 0,
|
||||
podiums: 0,
|
||||
races: 0,
|
||||
// Add mock data for new fields
|
||||
positionChange: Math.floor(Math.random() * 10) - 5, // -5 to +5
|
||||
lastRacePoints: Math.floor(Math.random() * 50),
|
||||
droppedRaceIds: [],
|
||||
}));
|
||||
this.result = { standings };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user