Фикс невозможности парсинга субботы.

class-validator.interceptor.ts
- Добавлена возможность возвращать клиенту любой DTO из списка.

Добавлен разный ответ клиенту в зависимости от его версии.
This commit is contained in:
2024-09-28 01:40:19 +04:00
parent 99dc3c86e7
commit d18a6764c9
8 changed files with 172 additions and 44 deletions

View File

@@ -31,6 +31,7 @@ export class ScheduleService {
private cacheHash: string = "0000000000000000000000000000000000000000";
private lastChangedDays: Array<Array<number>> = [];
private scheduleUpdatedAt: Date = new Date(0);
constructor(@Inject(CACHE_MANAGER) private readonly cacheManager: Cache) {}
@@ -39,6 +40,8 @@ export class ScheduleService {
cacheHash: this.cacheHash,
cacheUpdateRequired:
(Date.now() - this.cacheUpdatedAt.valueOf()) / 1000 / 60 >= 5,
lastCacheUpdate: this.cacheUpdatedAt.valueOf(),
lastScheduleUpdate: this.scheduleUpdatedAt.valueOf(),
};
}
@@ -50,11 +53,21 @@ export class ScheduleService {
) as Array<GroupDto>;
this.cacheUpdatedAt = new Date();
const oldHash = this.cacheHash;
this.cacheHash = crypto
.createHash("sha1")
.update(schedule.etag)
.update(
JSON.stringify(schedule.groups, null, 0) + schedule.etag,
)
.digest("hex");
if (
this.scheduleUpdatedAt.valueOf() === 0 ||
this.cacheHash !== oldHash
)
this.scheduleUpdatedAt = new Date();
return schedule;
});
}