mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00

* feat: add availability synchronization job fix #377 * fix: feedback on PR * perf: use pagination for Media Availability Synchronization job The original approach loaded all media items from the database at once. With large libraries, this could lead to performance issues. We're now using a paginated approach with a page size of 50. * feat: updated the availability sync to work with 4k * fix: corrected detection of media in plex * refactor: code cleanup and minimized unnecessary calls * fix: if media is not found, media check will continue * fix: if non-4k or 4k show media is updated, seasons and request is now properly updated * refactor: consolidated media updater into one function * fix: season requests are now removed if season has been deleted * refactor: removed joincolumn * fix: makes sure we will always check radarr/sonarr to see if media exists * fix: media will now only be updated to unavailable and deletion will be prevented * fix: changed types in Media entity * fix: prevent season deletion in preference of setting season to unknown --------- Co-authored-by: Jari Zwarts <jari@oberon.nl> Co-authored-by: Sebastian Kappen <sebastian@kappen.dev>
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { MediaRequestStatus } from '@server/constants/media';
|
|
import { getRepository } from '@server/datasource';
|
|
import {
|
|
AfterRemove,
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { MediaRequest } from './MediaRequest';
|
|
|
|
@Entity()
|
|
class SeasonRequest {
|
|
@PrimaryGeneratedColumn()
|
|
public id: number;
|
|
|
|
@Column()
|
|
public seasonNumber: number;
|
|
|
|
@Column({ type: 'int', default: MediaRequestStatus.PENDING })
|
|
public status: MediaRequestStatus;
|
|
|
|
@ManyToOne(() => MediaRequest, (request) => request.seasons, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
public request: MediaRequest;
|
|
|
|
@CreateDateColumn()
|
|
public createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
public updatedAt: Date;
|
|
|
|
constructor(init?: Partial<SeasonRequest>) {
|
|
Object.assign(this, init);
|
|
}
|
|
|
|
@AfterRemove()
|
|
public async handleRemoveParent(): Promise<void> {
|
|
const mediaRequestRepository = getRepository(MediaRequest);
|
|
const requestToBeDeleted = await mediaRequestRepository.findOneOrFail({
|
|
where: { id: this.request.id },
|
|
});
|
|
|
|
if (requestToBeDeleted.seasons.length === 0) {
|
|
await mediaRequestRepository.delete({ id: this.request.id });
|
|
}
|
|
}
|
|
}
|
|
|
|
export default SeasonRequest;
|