refactor
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
import { IProtestRepository } from '@core/racing/domain/repositories/IProtestRepository';
|
||||
import { Protest, ProtestStatus } from '@core/racing/domain/entities/Protest';
|
||||
import { Protest } from '@core/racing/domain/entities/Protest';
|
||||
import { Logger } from '@core/shared/application';
|
||||
|
||||
export class InMemoryProtestRepository implements IProtestRepository {
|
||||
private protests: Map<string, Protest> = new Map();
|
||||
|
||||
constructor(private readonly logger: Logger, initialProtests: Protest[] = []) {
|
||||
constructor(private readonly logger: Logger) {
|
||||
this.logger.info('InMemoryProtestRepository initialized.');
|
||||
for (const protest of initialProtests) {
|
||||
this.protests.set(protest.id, protest);
|
||||
this.logger.debug(`Seeded protest: ${protest.id}.`);
|
||||
}
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<Protest | null> {
|
||||
@@ -47,14 +43,14 @@ export class InMemoryProtestRepository implements IProtestRepository {
|
||||
|
||||
async findPending(): Promise<Protest[]> {
|
||||
this.logger.debug('[InMemoryProtestRepository] Finding all pending protests.');
|
||||
const pendingProtests = Array.from(this.protests.values()).filter(p => p.status === 'pending');
|
||||
const pendingProtests = Array.from(this.protests.values()).filter(p => p.status.toString() === 'pending');
|
||||
this.logger.info(`Found ${pendingProtests.length} pending protests.`);
|
||||
return Promise.resolve(pendingProtests);
|
||||
}
|
||||
|
||||
async findUnderReviewBy(stewardId: string): Promise<Protest[]> {
|
||||
this.logger.debug(`[InMemoryProtestRepository] Finding protests under review by steward: ${stewardId}.`);
|
||||
const underReviewProtests = Array.from(this.protests.values()).filter(p => p.reviewedBy === stewardId && p.status === 'under_review');
|
||||
const underReviewProtests = Array.from(this.protests.values()).filter(p => p.reviewedBy === stewardId && p.status.toString() === 'under_review');
|
||||
this.logger.info(`Found ${underReviewProtests.length} protests under review by steward ${stewardId}.`);
|
||||
return Promise.resolve(underReviewProtests);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user