-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(episodes): add episode availability tracking and sync #1671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
0xSysR3ll
wants to merge
33
commits into
seerr-team:develop
from
0xSysR3ll:feat-episode-availability
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
3de15af
feat(episodes): add episode availability tracking and sync
0xSysR3ll 424686c
chore(tv): removed the wrong parameter.
0xSysR3ll 08f9291
feat(settings): make the feature optionnal
0xSysR3ll 5150495
fix(ui): only display availability if provider is tvdb
0xSysR3ll ec2da54
fix(api): only mark episode as available if provider is tvdb
0xSysR3ll 341fc67
fix(cypress): add missing newline
0xSysR3ll b0fbdaa
fix(tv): rely on provider type instead of setting
0xSysR3ll d1575af
feat(settings): add metadata settings for TV and anime
0xSysR3ll 87367d0
refactor(tv): simplify episode availability checks
0xSysR3ll 7511054
fix(settings): missing metadata settings
0xSysR3ll 32b513f
feat(availability): implement episode caching
0xSysR3ll bf4b330
refactor(season): make episodes property optional and remove eager lo…
0xSysR3ll 9bc7ef6
refactor(api): remove getEpisodesBySeriesId method and update availab…
0xSysR3ll c865f88
chore: apply linting
0xSysR3ll 25334fa
refactor(tv): change getSettings to synchronous call
0xSysR3ll 2708293
refactor(availability): enhance episode tracking logic in availabilit…
0xSysR3ll 3750dde
chore: restore old changes
0xSysR3ll fc42626
chore: reapply linting
0xSysR3ll 0bfba86
feat(migration): add episode table migrations
0xSysR3ll b0207ae
feat(episode): add index on season
0xSysR3ll 8cfa30e
feat(settings): add warning for episode availability without TVDB set
0xSysR3ll 813ae1e
refactor(migration): replace old episode table migration with to incl…
0xSysR3ll 26f9390
refactor(episode): move index on ManyToOne relationship with Season
0xSysR3ll fae2ae6
refactor(Episode): we shouldn't use onUpdate
0xSysR3ll 48de4fc
feat: update migrations
0xSysR3ll 371dc7a
chore: remove old migrations
0xSysR3ll 713da44
chore: upgrade migrations
0xSysR3ll 047e60d
chore: update db migrations
0xSysR3ll 3cc7551
fix: omit episode availability when tracking is disabled
0xSysR3ll b17f2a5
fix(tv): handle episode number mismatches in availability checks
0xSysR3ll 2b9bb5d
fix: clarify tracking message in settings
0xSysR3ll 68da743
refactor: load episode relations only in the season route
0xSysR3ll 270b450
fix: keep episode availability out of availability sync
0xSysR3ll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { MediaStatus } from '@server/constants/media'; | ||
| import { DbAwareColumn, resolveDbType } from '@server/utils/DbColumnHelper'; | ||
| import { | ||
| Column, | ||
| Entity, | ||
| Index, | ||
| ManyToOne, | ||
| PrimaryGeneratedColumn, | ||
| UpdateDateColumn, | ||
| } from 'typeorm'; | ||
| import Season from './Season'; | ||
|
|
||
| @Entity() | ||
| class Episode { | ||
| @PrimaryGeneratedColumn() | ||
| public id: number; | ||
|
|
||
| @Column() | ||
| public episodeNumber: number; | ||
|
|
||
| @Column({ type: 'int', default: MediaStatus.UNKNOWN }) | ||
| public status: MediaStatus; | ||
|
|
||
| @Column({ type: 'int', default: MediaStatus.UNKNOWN }) | ||
| public status4k: MediaStatus; | ||
|
|
||
| @Index() | ||
| @ManyToOne(() => Season, (season: Season) => season.episodes, { | ||
| onDelete: 'CASCADE', | ||
| nullable: true, | ||
| }) | ||
| public season?: Promise<Season>; | ||
|
|
||
| @DbAwareColumn({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) | ||
| public createdAt: Date; | ||
|
|
||
| @UpdateDateColumn({ | ||
| type: resolveDbType('datetime'), | ||
| default: () => 'CURRENT_TIMESTAMP', | ||
| }) | ||
| public updatedAt: Date; | ||
|
|
||
| constructor(init?: Partial<Episode>) { | ||
| if (init) { | ||
| Object.assign(this, init); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default Episode; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
0xSysR3ll marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
server/migration/postgres/1780843263648-AddEpisodeTable.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class AddEpisodeTable1780843263648 implements MigrationInterface { | ||
| name = 'AddEpisodeTable1780843263648'; | ||
|
|
||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `CREATE TABLE "episode" ("id" SERIAL NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT '1', "status4k" integer NOT NULL DEFAULT '1', "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "seasonId" integer, CONSTRAINT "PK_7258b95d6d2bf7f621845a0e143" PRIMARY KEY ("id"))` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") ` | ||
| ); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "episode" ADD CONSTRAINT "FK_e73d28c1e5e3c85125163f7c9cd" FOREIGN KEY ("seasonId") REFERENCES "season"("id") ON DELETE CASCADE ON UPDATE NO ACTION` | ||
| ); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `ALTER TABLE "episode" DROP CONSTRAINT "FK_e73d28c1e5e3c85125163f7c9cd"` | ||
| ); | ||
| await queryRunner.query( | ||
| `DROP INDEX "public"."IDX_e73d28c1e5e3c85125163f7c9c"` | ||
| ); | ||
| await queryRunner.query(`DROP TABLE "episode"`); | ||
| } | ||
| } |
103 changes: 103 additions & 0 deletions
103
server/migration/sqlite/1780843239768-AddEpisodeTable.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import type { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class AddEpisodeTable1780843239768 implements MigrationInterface { | ||
| name = 'AddEpisodeTable1780843239768'; | ||
|
|
||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)` | ||
| ); | ||
| await queryRunner.query( | ||
| `INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"` | ||
| ); | ||
| await queryRunner.query(`DROP TABLE "user_push_subscription"`); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "temporary_user_push_subscription" RENAME TO "user_push_subscription"` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") ` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "episode" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "status4k" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "updatedAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "seasonId" integer)` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") ` | ||
| ); | ||
| await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)` | ||
| ); | ||
| await queryRunner.query( | ||
| `INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"` | ||
| ); | ||
| await queryRunner.query(`DROP TABLE "user_push_subscription"`); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "temporary_user_push_subscription" RENAME TO "user_push_subscription"` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") ` | ||
| ); | ||
| await queryRunner.query(`DROP INDEX "IDX_e73d28c1e5e3c85125163f7c9c"`); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "temporary_episode" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "status4k" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "updatedAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "seasonId" integer, CONSTRAINT "FK_e73d28c1e5e3c85125163f7c9cd" FOREIGN KEY ("seasonId") REFERENCES "season" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)` | ||
| ); | ||
| await queryRunner.query( | ||
| `INSERT INTO "temporary_episode"("id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId") SELECT "id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId" FROM "episode"` | ||
| ); | ||
| await queryRunner.query(`DROP TABLE "episode"`); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "temporary_episode" RENAME TO "episode"` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") ` | ||
| ); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(`DROP INDEX "IDX_e73d28c1e5e3c85125163f7c9c"`); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "episode" RENAME TO "temporary_episode"` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "episode" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "episodeNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "status4k" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "updatedAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "seasonId" integer)` | ||
| ); | ||
| await queryRunner.query( | ||
| `INSERT INTO "episode"("id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId") SELECT "id", "episodeNumber", "status", "status4k", "createdAt", "updatedAt", "seasonId" FROM "temporary_episode"` | ||
| ); | ||
| await queryRunner.query(`DROP TABLE "temporary_episode"`); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_e73d28c1e5e3c85125163f7c9c" ON "episode" ("seasonId") ` | ||
| ); | ||
| await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "user_push_subscription" RENAME TO "temporary_user_push_subscription"` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)` | ||
| ); | ||
| await queryRunner.query( | ||
| `INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"` | ||
| ); | ||
| await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") ` | ||
| ); | ||
| await queryRunner.query(`DROP INDEX "IDX_e73d28c1e5e3c85125163f7c9c"`); | ||
| await queryRunner.query(`DROP TABLE "episode"`); | ||
| await queryRunner.query(`DROP INDEX "IDX_03f7958328e311761b0de675fb"`); | ||
| await queryRunner.query( | ||
| `ALTER TABLE "user_push_subscription" RENAME TO "temporary_user_push_subscription"` | ||
| ); | ||
| await queryRunner.query( | ||
| `CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (CURRENT_TIMESTAMP), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "UQ_6427d07d9a171a3a1ab87480005" UNIQUE ("endpoint", "userId"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)` | ||
| ); | ||
| await queryRunner.query( | ||
| `INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"` | ||
| ); | ||
| await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`); | ||
| await queryRunner.query( | ||
| `CREATE INDEX "IDX_03f7958328e311761b0de675fb" ON "user_push_subscription" ("userId") ` | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.