Fixed movie duration returned as string, therefore failing formatting.

This commit is contained in:
DebaucheryLibrarian 2024-10-27 22:51:04 +01:00
parent fa560c179b
commit 5ff522311e
2 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -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);