feat: library page sections, sorting, view options

fix: tmdb library items not being cached
This commit is contained in:
Aleksi Lassila
2025-02-15 05:03:20 +02:00
parent 8f83a34b35
commit ef4fa1d13a
21 changed files with 575 additions and 178 deletions

View File

@@ -6,6 +6,7 @@ import {
UpdateDateColumn,
} from 'typeorm';
import { TmdbMovieFull, TmdbSeriesFull } from './tmdb/tmdb.dto';
import { TMDB_CACHE_TTL } from 'src/consts';
@Entity()
export class Movie {
@@ -21,6 +22,7 @@ export class Movie {
@Column('json')
tmdbMovie: TmdbMovieFull;
@ApiProperty({ type: 'string' })
@UpdateDateColumn()
updatedAt: Date;
}
@@ -39,6 +41,33 @@ export class Series {
@Column('json')
tmdbSeries: TmdbSeriesFull;
@ApiProperty({ type: 'string' })
@UpdateDateColumn()
updatedAt: Date;
isStale() {
console.log(this.updatedAt);
if (!this.updatedAt) return true;
console.log(
new Date().getTime() - this.updatedAt.getTime(),
TMDB_CACHE_TTL,
);
if (new Date().getTime() - this.updatedAt.getTime() > TMDB_CACHE_TTL)
return true;
console.log(
'Checking if series is stale',
this.tmdbSeries.name,
this.tmdbSeries.next_episode_to_air?.air_date,
);
if (
this.tmdbSeries?.next_episode_to_air?.air_date &&
new Date() > new Date(this.tmdbSeries.next_episode_to_air.air_date)
) {
return true;
}
return false;
}
}