53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import type { Logger, UseCase } from '@core/shared/application';
|
|
import { Result } from '@core/shared/domain/Result';
|
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
|
|
|
export interface GetDashboardDataInput {}
|
|
|
|
export interface GetDashboardDataOutput {
|
|
totalUsers: number;
|
|
activeUsers: number;
|
|
totalRaces: number;
|
|
totalLeagues: number;
|
|
}
|
|
|
|
export type GetDashboardDataErrorCode = 'REPOSITORY_ERROR';
|
|
|
|
export class GetDashboardDataUseCase implements UseCase<GetDashboardDataInput, GetDashboardDataOutput, GetDashboardDataErrorCode> {
|
|
constructor(
|
|
private readonly logger: Logger,
|
|
) {}
|
|
|
|
async execute(): Promise<Result<GetDashboardDataOutput, ApplicationErrorCode<GetDashboardDataErrorCode, { message: string }>>> {
|
|
try {
|
|
// Placeholder implementation - would need repositories from identity and racing domains
|
|
const totalUsers = 0;
|
|
const activeUsers = 0;
|
|
const totalRaces = 0;
|
|
const totalLeagues = 0;
|
|
|
|
const resultModel: GetDashboardDataOutput = {
|
|
totalUsers,
|
|
activeUsers,
|
|
totalRaces,
|
|
totalLeagues,
|
|
};
|
|
|
|
this.logger.info('Dashboard data retrieved', {
|
|
totalUsers,
|
|
activeUsers,
|
|
totalRaces,
|
|
totalLeagues,
|
|
});
|
|
|
|
return Result.ok(resultModel);
|
|
} catch (error) {
|
|
const err = error as Error;
|
|
this.logger.error('Failed to get dashboard data', err);
|
|
return Result.err({
|
|
code: 'REPOSITORY_ERROR',
|
|
details: { message: err.message ?? 'Failed to get dashboard data' },
|
|
});
|
|
}
|
|
}
|
|
} |