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,
|
||||
} = await promiseProps({
|
||||
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('releases', 'releases.id', 'movies_scenes.scene_id')
|
||||
.whereIn('movies.id', movieIds)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { format } from 'date-fns';
|
||||
|
||||
export function formatDuration(duration, forceHours) {
|
||||
if (typeof duration !== 'number') {
|
||||
return duration;
|
||||
export function formatDuration(rawDuration, forceHours) {
|
||||
const duration = Number(rawDuration);
|
||||
|
||||
if (Number.isNaN(duration)) {
|
||||
return rawDuration;
|
||||
}
|
||||
|
||||
const hours = Math.floor(duration / 3600);
|
||||
|
|
Loading…
Reference in New Issue