1 parent
40d579cdb9
commit
382cafa152
8 files changed
+25
-9
No files matched your search
+9
@@ -44,4 +44,13 @@ describe('GetIssueStatsUseCase', () => {
|
||||
expect(stats.total).toBe(0);
|
||||
expect(stats.byStatus.every((entry) => entry.count === 0)).toBe(true);
|
||||
});
|
||||
|
||||
it('passes projectId through to the repository to filter stats by project', async () => {
|
||||
vi.mocked(repository.countByStatus).mockResolvedValue([{ status: 'OPEN', count: 3 }]);
|
||||
|
||||
const stats = await useCase.execute('user-1', 'project-1');
|
||||
|
||||
expect(repository.countByStatus).toHaveBeenCalledWith('user-1', 'project-1');
|
||||
expect(stats.total).toBe(3);
|
||||
});
|
||||
});
|
||||
@@ -10,8 +10,8 @@ export class GetIssueStatsUseCase {
|
||||
private readonly issueRepository: IIssueRepository,
|
||||
) {}
|
||||
|
||||
async execute(userId: string): Promise<IssueStatsDto> {
|
||||
const counts = await this.issueRepository.countByStatus(userId);
|
||||
async execute(userId: string, projectId?: string): Promise<IssueStatsDto> {
|
||||
const counts = await this.issueRepository.countByStatus(userId, projectId);
|
||||
const countByStatus = new Map(counts.map((entry) => [entry.status, entry.count]));
|
||||
|
||||
// Каждый известный статус попадает в ответ, даже если по нему 0 задач
|
||||
|
||||
Reference in new issue
Block a user