mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:06:56 -04:00
* refactor: api validators (boolean and date) * chore: open api * revert: time bucket change
35 lines
866 B
TypeScript
35 lines
866 B
TypeScript
import { AssetType } from '@app/infra/entities';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
import { ValidateBoolean } from '../../domain.util';
|
|
import { AssetStats } from '../../repositories';
|
|
|
|
export class AssetStatsDto {
|
|
@ValidateBoolean({ optional: true })
|
|
isArchived?: boolean;
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
isFavorite?: boolean;
|
|
|
|
@ValidateBoolean({ optional: true })
|
|
isTrashed?: boolean;
|
|
}
|
|
|
|
export class AssetStatsResponseDto {
|
|
@ApiProperty({ type: 'integer' })
|
|
images!: number;
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
videos!: number;
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
total!: number;
|
|
}
|
|
|
|
export const mapStats = (stats: AssetStats): AssetStatsResponseDto => {
|
|
return {
|
|
images: stats[AssetType.IMAGE],
|
|
videos: stats[AssetType.VIDEO],
|
|
total: Object.values(stats).reduce((total, value) => total + value, 0),
|
|
};
|
|
};
|