func ToBasicJSON(reader models.SceneReader, scene *models.Scene) (*jsonschema.Scene, error) {
	newSceneJSON := jsonschema.Scene{
		CreatedAt: json.JSONTime{Time: scene.CreatedAt.Timestamp},
		UpdatedAt: json.JSONTime{Time: scene.UpdatedAt.Timestamp},
	}

	if scene.Checksum.Valid {
		newSceneJSON.Checksum = scene.Checksum.String
	}

	if scene.OSHash.Valid {
		newSceneJSON.OSHash = scene.OSHash.String
	}

	if scene.Phash.Valid {
		newSceneJSON.Phash = utils.PhashToString(scene.Phash.Int64)
	}

	if scene.Title.Valid {
		newSceneJSON.Title = scene.Title.String
	}

	if scene.URL.Valid {
		newSceneJSON.URL = scene.URL.String
	}

	if scene.Date.Valid {
		newSceneJSON.Date = utils.GetYMDFromDatabaseDate(scene.Date.String)
	}

	if scene.Rating.Valid {
		newSceneJSON.Rating = int(scene.Rating.Int64)
	}

	newSceneJSON.Organized = scene.Organized
	newSceneJSON.OCounter = scene.OCounter

	if scene.Details.Valid {
		newSceneJSON.Details = scene.Details.String
	}

	newSceneJSON.File = getSceneFileJSON(scene)

	cover, err := reader.GetCover(scene.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting scene cover: %v", err)
	}

	if len(cover) > 0 {
		newSceneJSON.Cover = utils.GetBase64StringFromData(cover)
	}

	stashIDs, _ := reader.GetStashIDs(scene.ID)
	var ret []models.StashID
	for _, stashID := range stashIDs {
		newJoin := models.StashID{
			StashID:  stashID.StashID,
			Endpoint: stashID.Endpoint,
		}
		ret = append(ret, newJoin)
	}

	newSceneJSON.StashIDs = ret

	return &newSceneJSON, nil
}
// ToBasicJSON converts a scene object into its JSON object equivalent. It
// does not convert the relationships to other objects, with the exception
// of cover image.
ToBasicJSON converts a scene object into its JSON object equivalent. It
does not convert the relationships to other objects, with the exception
of cover image.
// ToBasicJSON converts a scene object into its JSON object equivalent . It // does not convert the relationships to other objects with the exception // of cover image .
func ToBasicJSON(reader models.SceneReader, scene *models.Scene) (*jsonschema.Scene, error) {
	newSceneJSON := jsonschema.Scene{
		CreatedAt: json.JSONTime{Time: scene.CreatedAt.Timestamp},
		UpdatedAt: json.JSONTime{Time: scene.UpdatedAt.Timestamp},
	}
	if scene.Checksum.Valid {
		newSceneJSON.Checksum = scene.Checksum.String
	}
	if scene.OSHash.Valid {
		newSceneJSON.OSHash = scene.OSHash.String
	}
	if scene.Phash.Valid {
		newSceneJSON.Phash = utils.PhashToString(scene.Phash.Int64)
	}
	if scene.Title.Valid {
		newSceneJSON.Title = scene.Title.String
	}
	if scene.URL.Valid {
		newSceneJSON.URL = scene.URL.String
	}
	if scene.Date.Valid {
		newSceneJSON.Date = utils.GetYMDFromDatabaseDate(scene.Date.String)
	}
	if scene.Rating.Valid {
		newSceneJSON.Rating = int(scene.Rating.Int64)
	}
	newSceneJSON.Organized = scene.Organized
	newSceneJSON.OCounter = scene.OCounter
	if scene.Details.Valid {
		newSceneJSON.Details = scene.Details.String
	}
	newSceneJSON.File = getSceneFileJSON(scene)
	cover, err := reader.GetCover(scene.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting scene cover: %v", err)
	}
	if len(cover) > 0 {
		newSceneJSON.Cover = utils.GetBase64StringFromData(cover)
	}
	stashIDs, _ := reader.GetStashIDs(scene.ID)
	var ret []models.StashID
	for _, stashID := range stashIDs {
		newJoin := models.StashID{
			StashID:  stashID.StashID,
			Endpoint: stashID.Endpoint,
		}
		ret = append(ret, newJoin)
	}
	newSceneJSON.StashIDs = ret
	return &newSceneJSON, nil
}
func ToBasicJSON ( reader models . SceneReader , scene * models . Scene ) ( * jsonschema . Scene , error ) { newSceneJSON := jsonschema . Scene { CreatedAt : json . JSONTime { Time : scene . CreatedAt . Timestamp } , UpdatedAt : json . JSONTime { Time : scene . UpdatedAt . Timestamp } , } if scene . Checksum . Valid { newSceneJSON . Checksum = scene . Checksum . String } if scene . OSHash . Valid { newSceneJSON . OSHash = scene . OSHash . String } if scene . Phash . Valid { newSceneJSON . Phash = utils . PhashToString ( scene . Phash . Int64 ) } if scene . Title . Valid { newSceneJSON . Title = scene . Title . String } if scene . URL . Valid { newSceneJSON . URL = scene . URL . String } if scene . Date . Valid { newSceneJSON . Date = utils . GetYMDFromDatabaseDate ( scene . Date . String ) } if scene . Rating . Valid { newSceneJSON . Rating = int ( scene . Rating . Int64 ) } newSceneJSON . Organized = scene . Organized newSceneJSON . OCounter = scene . OCounter if scene . Details . Valid { newSceneJSON . Details = scene . Details . String } newSceneJSON . File = getSceneFileJSON ( scene ) cover , err := reader . GetCover ( scene . ID ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if len ( cover ) > 0 { newSceneJSON . Cover = utils . GetBase64StringFromData ( cover ) } stashIDs , _ := reader . GetStashIDs ( scene . ID ) var ret [ ] models . StashID for _ , stashID := range stashIDs { newJoin := models . StashID { StashID : stashID . StashID , Endpoint : stashID . Endpoint , } ret = append ( ret , newJoin ) } newSceneJSON . StashIDs = ret return & newSceneJSON , nil }
ToBasicJSON converts a scene object into its JSON object equivalent.
ToBasicJSON converts a scene object into its JSON object equivalent .