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,
skip: offset,
take: pageSize,
order: { id: 'DESC' },
}));
offset += pageSize;
} while (mediaPage.length > 0);

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

Loading…
Cancel
Save