mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-27 03:05:10 +02:00
feat: library page sections, sorting, view options
fix: tmdb library items not being cached
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user