File

apps/recallassess/recallassess-api/src/api/client/learning-group/dto/learning-group-list-response.dto.ts

Description

Extended metadata specifically for learning group list responses Includes learning group status counts and total participants count

Index

Properties

Properties

active_count
Type : number
Decorators :
@Expose()
@ApiProperty({description: 'Total count of active learning groups', example: 15})
cancelled_count
Type : number
Decorators :
@Expose()
@ApiProperty({description: 'Total count of cancelled learning groups', example: 2})
completed_count
Type : number
Decorators :
@Expose()
@ApiProperty({description: 'Total count of completed learning groups', example: 8})
pending_count
Type : number
Decorators :
@Expose()
@ApiProperty({description: 'Total count of pending learning groups', example: 5})
total_participants_count
Type : number
Decorators :
@Expose()
@ApiProperty({description: 'Total count of participants across all learning groups', example: 250})
import { CLListResponse, CLMetaData } from "@api/shared/dto";
import { ApiProperty } from "@nestjs/swagger";
import { Exclude, Expose } from "class-transformer";
import { CLLearningGroupDto } from "./learning-group.dto";

/**
 * Extended metadata specifically for learning group list responses
 * Includes learning group status counts and total participants count
 */
@Exclude()
export class CLLearningGroupMetaData extends CLMetaData {
  @Expose()
  @ApiProperty({ description: "Total count of active learning groups", example: 15 })
  active_count!: number;

  @Expose()
  @ApiProperty({ description: "Total count of completed learning groups", example: 8 })
  completed_count!: number;

  @Expose()
  @ApiProperty({ description: "Total count of pending learning groups", example: 5 })
  pending_count!: number;

  @Expose()
  @ApiProperty({ description: "Total count of cancelled learning groups", example: 2 })
  cancelled_count!: number;

  @Expose()
  @ApiProperty({ description: "Total count of participants across all learning groups", example: 250 })
  total_participants_count!: number;
}

/**
 * Learning group-specific list response
 * Uses extended metadata that includes learning group status counts and total participants
 */
@Exclude()
export class CLLearningGroupListResponse extends CLListResponse<CLLearningGroupDto> {
  @ApiProperty({ description: "Array of learning group data items", type: [CLLearningGroupDto] })
  declare data: CLLearningGroupDto[];

  @ApiProperty({ description: "Pagination metadata with learning group counts", type: CLLearningGroupMetaData })
  declare meta: CLLearningGroupMetaData;

  constructor(
    data: CLLearningGroupDto[],
    page: number,
    limit: number,
    totalCount: number,
    activeCount: number,
    completedCount: number,
    pendingCount: number,
    cancelledCount: number,
    totalParticipantsCount: number,
  ) {
    super(data, page, limit, totalCount);

    // Override meta with extended metadata
    this.meta = {
      page,
      limit,
      total_count: totalCount,
      total_pages: Math.ceil(totalCount / limit),
      has_next_page: page * limit < totalCount,
      has_previous_page: page > 1,
      active_count: activeCount,
      completed_count: completedCount,
      pending_count: pendingCount,
      cancelled_count: cancelledCount,
      total_participants_count: totalParticipantsCount,
    };
  }
}

results matching ""

    No results matching ""