fix: mark available button correctly sets requests as completed

pull/3460/head
Brandon 2 years ago committed by OwsleyJr
parent 390000d6d4
commit d5e3f1cd0b

@ -238,7 +238,6 @@ class AvailabilitySync {
where: whereOptions, where: whereOptions,
skip: offset, skip: offset,
take: pageSize, take: pageSize,
order: { id: 'DESC' },
})); }));
offset += pageSize; offset += pageSize;
} while (mediaPage.length > 0); } while (mediaPage.length > 0);

@ -147,19 +147,25 @@ mediaRoutes.post<
} }
if (req.params.status === 'available') { if (req.params.status === 'available') {
const request = await requestRepository.findOne({ const requests = await requestRepository.find({
relations: { relations: {
media: true, media: true,
}, },
where: { media: { id: media.id }, is4k: is4k }, where: { media: { id: media.id }, is4k: is4k },
}); });
const requestIds = requests.map((request) => request.id);
if (requestIds.length > 0) {
await requestRepository.update( await requestRepository.update(
{ media: { id: request?.id } }, { id: In(requestIds) },
{ status: MediaRequestStatus.COMPLETED } { status: MediaRequestStatus.COMPLETED }
); );
}
request?.seasons.forEach(async (season) => { requests
.flatMap((request) => request.seasons)
.forEach(async (season) => {
await seasonRequestRepository.update(season.id, { await seasonRequestRepository.update(season.id, {
status: MediaRequestStatus.COMPLETED, status: MediaRequestStatus.COMPLETED,
}); });

Loading…
Cancel
Save