-
-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scraped movie to create input translation (#3969)
- Loading branch information
1 parent
a354f9b
commit 170f45c
Showing
5 changed files
with
76 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as GQL from "src/core/generated-graphql"; | ||
import DurationUtils from "src/utils/duration"; | ||
|
||
export const scrapedMovieToCreateInput = (toCreate: GQL.ScrapedMovie) => { | ||
const input: GQL.MovieCreateInput = { | ||
name: toCreate.name ?? "", | ||
url: toCreate.url, | ||
aliases: toCreate.aliases, | ||
front_image: toCreate.front_image, | ||
back_image: toCreate.back_image, | ||
synopsis: toCreate.synopsis, | ||
date: toCreate.date, | ||
// #788 - convert duration and rating to the correct type | ||
duration: toCreate.duration | ||
? DurationUtils.stringToSeconds(toCreate.duration) | ||
: undefined, | ||
studio_id: toCreate.studio?.stored_id, | ||
rating: parseInt(toCreate.rating ?? "0", 10), | ||
}; | ||
|
||
if (!input.duration) { | ||
input.duration = undefined; | ||
} | ||
|
||
if (!input.rating || Number.isNaN(input.rating)) { | ||
input.rating = undefined; | ||
} | ||
|
||
return input; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters