Skip to content

Commit

Permalink
[polish] ActivityAgendaCheckInSummary class
Browse files Browse the repository at this point in the history
  • Loading branch information
Soecka committed Jan 5, 2025
1 parent e37e3fa commit eb2db30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
6 changes: 0 additions & 6 deletions src/model/Base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Type } from 'class-transformer';
import {
IsDateString,
IsEnum,
IsInt,
IsOptional,
IsString,
Expand All @@ -14,11 +13,6 @@ import {
UpdateDateColumn
} from 'typeorm';

export enum Sort {
DESC = 'DESC',
ASC = 'ASC'
}

export abstract class Base {
constructor(id?: number) {
if (id) this.id = id;
Expand Down
45 changes: 16 additions & 29 deletions src/model/CheckEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,12 @@ export class UserActivityCheckInSummary {
connection
.createQueryBuilder()
.from(CheckEvent, 'ce')
.groupBy('ce.activityId, ce.agendaId')
.groupBy('ce.activityId')
.select('ce.activityId', 'activityId')
.addSelect('ce.activityName', 'activityName')
.addSelect('ce.agendaId', 'agendaId')
.addSelect('ce.agendaTitle', 'agendaTitle')
.addSelect('COUNT(ce.id)', 'checkCount')
})
export class ActivityAgendaCheckInSummary {
export class ActivityCheckInSummary {
@ViewColumn()
@IsString()
activityId: string;
Expand All @@ -148,14 +146,6 @@ export class ActivityAgendaCheckInSummary {
@IsString()
activityName: string;

@ViewColumn()
@IsString()
agendaId: string;

@ViewColumn()
@IsString()
agendaTitle: string;

@ViewColumn()
@IsInt()
@Min(0)
Expand All @@ -167,24 +157,21 @@ export class ActivityAgendaCheckInSummary {
connection
.createQueryBuilder()
.from(CheckEvent, 'ce')
.groupBy('ce.activityId')
.groupBy('ce.activityId, ce.agendaId')
.select('ce.activityId', 'activityId')
.addSelect('ce.activityName', 'activityName')
.addSelect('ce.agendaId', 'agendaId')
.addSelect('ce.agendaTitle', 'agendaTitle')
.addSelect('COUNT(ce.id)', 'checkCount')
})
export class ActivityCheckInSummary {
export class ActivityAgendaCheckInSummary extends ActivityCheckInSummary {
@ViewColumn()
@IsString()
activityId: string;
agendaId: string;

@ViewColumn()
@IsString()
activityName: string;

@ViewColumn()
@IsInt()
@Min(0)
checkCount: number;
agendaTitle: string;
}

export class UserActivityCheckInListChunk
Expand All @@ -199,26 +186,26 @@ export class UserActivityCheckInListChunk
list: UserActivityCheckInSummary[];
}

export class ActivityAgendaCheckInListChunk
implements ListChunk<ActivityAgendaCheckInSummary>
export class ActivityCheckInListChunk
implements ListChunk<ActivityCheckInSummary>
{
@IsInt()
@Min(0)
count: number;

@Type(() => ActivityAgendaCheckInSummary)
@Type(() => ActivityCheckInSummary)
@ValidateNested({ each: true })
list: ActivityAgendaCheckInSummary[];
list: ActivityCheckInSummary[];
}

export class ActivityCheckInListChunk
implements ListChunk<ActivityCheckInSummary>
export class ActivityAgendaCheckInListChunk
implements ListChunk<ActivityAgendaCheckInSummary>
{
@IsInt()
@Min(0)
count: number;

@Type(() => ActivityCheckInSummary)
@Type(() => ActivityAgendaCheckInSummary)
@ValidateNested({ each: true })
list: ActivityCheckInSummary[];
list: ActivityAgendaCheckInSummary[];
}

0 comments on commit eb2db30

Please sign in to comment.