Fixed movie duration returned as string, therefore failing formatting.
This commit is contained in:
parent
fa560c179b
commit
5ff522311e
|
@ -79,7 +79,7 @@ export async function fetchMoviesById(movieIds, reqUser) {
|
||||||
stashes,
|
stashes,
|
||||||
} = await promiseProps({
|
} = await promiseProps({
|
||||||
movies: knex('movies')
|
movies: knex('movies')
|
||||||
.select('movies.*', knex.raw('sum(releases.duration) as duration'))
|
.select('movies.*', knex.raw('cast(sum(releases.duration) as integer) as duration'))
|
||||||
.leftJoin('movies_scenes', 'movies_scenes.movie_id', 'movies.id')
|
.leftJoin('movies_scenes', 'movies_scenes.movie_id', 'movies.id')
|
||||||
.leftJoin('releases', 'releases.id', 'movies_scenes.scene_id')
|
.leftJoin('releases', 'releases.id', 'movies_scenes.scene_id')
|
||||||
.whereIn('movies.id', movieIds)
|
.whereIn('movies.id', movieIds)
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
|
|
||||||
export function formatDuration(duration, forceHours) {
|
export function formatDuration(rawDuration, forceHours) {
|
||||||
if (typeof duration !== 'number') {
|
const duration = Number(rawDuration);
|
||||||
return duration;
|
|
||||||
|
if (Number.isNaN(duration)) {
|
||||||
|
return rawDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hours = Math.floor(duration / 3600);
|
const hours = Math.floor(duration / 3600);
|
||||||
|
|
Loading…
Reference in New Issue