[Feature] Images new fields : URL & Date (#3015)

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
HijackHornet
2022-12-20 01:13:41 +01:00
committed by GitHub
parent cc4b0f7b11
commit 0b4b100ecc
23 changed files with 191 additions and 15 deletions

View File

@@ -885,9 +885,9 @@ func getObjectDate(index int) models.SQLiteDate {
}
}
func getObjectDateObject(index int) *models.Date {
func getObjectDateObject(index int, fromDB bool) *models.Date {
d := getObjectDate(index)
if !d.Valid {
if !d.Valid || (fromDB && (d.String == "" || d.String == "0001-01-01")) {
return nil
}
@@ -998,7 +998,7 @@ func makeScene(i int) *models.Scene {
URL: getSceneEmptyString(i, urlField),
Rating: getIntPtr(rating),
OCounter: getOCounter(i),
Date: getObjectDateObject(i),
Date: getObjectDateObject(i, false),
StudioID: studioID,
GalleryIDs: models.NewRelatedIDs(gids),
PerformerIDs: models.NewRelatedIDs(pids),
@@ -1063,7 +1063,7 @@ func makeImageFile(i int) *file.ImageFile {
}
}
func makeImage(i int) *models.Image {
func makeImage(i int, fromDB bool) *models.Image {
title := getImageStringValue(i, titleField)
var studioID *int
if _, ok := imageStudios[i]; ok {
@@ -1078,6 +1078,8 @@ func makeImage(i int) *models.Image {
return &models.Image{
Title: title,
Rating: getIntPtr(getRating(i)),
Date: getObjectDateObject(i, fromDB),
URL: getImageStringValue(i, urlField),
OCounter: getOCounter(i),
StudioID: studioID,
GalleryIDs: models.NewRelatedIDs(gids),
@@ -1101,7 +1103,7 @@ func createImages(ctx context.Context, n int) error {
}
imageFileIDs = append(imageFileIDs, f.ID)
image := makeImage(i)
image := makeImage(i, false)
err := qb.Create(ctx, &models.ImageCreateInput{
Image: image,
@@ -1162,7 +1164,7 @@ func makeGallery(i int, includeScenes bool) *models.Gallery {
Title: getGalleryStringValue(i, titleField),
URL: getGalleryNullStringValue(i, urlField).String,
Rating: getIntPtr(getRating(i)),
Date: getObjectDateObject(i),
Date: getObjectDateObject(i, false),
StudioID: studioID,
PerformerIDs: models.NewRelatedIDs(pids),
TagIDs: models.NewRelatedIDs(tids),