fix: address code review findings
This commit is contained in:
@@ -24,9 +24,9 @@ func FormatCachedAt(t time.Time) interface{} {
|
||||
return t.UTC().Format(utcLayout)
|
||||
}
|
||||
|
||||
// joinSecondaryTypes renders a slice of secondary types as a comma-separated
|
||||
// JoinSecondaryTypes renders a slice of secondary types as a comma-separated
|
||||
// string for storage in the secondary_types TEXT column (empty when none).
|
||||
func joinSecondaryTypes(types []string) string {
|
||||
func JoinSecondaryTypes(types []string) string {
|
||||
return strings.Join(types, ",")
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func SaveExternalRelease(db *DB, release *ExternalRelease) error {
|
||||
var cachedAt interface{} = FormatCachedAt(release.CachedAt)
|
||||
_, err := db.Conn().Exec(
|
||||
"INSERT OR REPLACE INTO external_releases (rgid, artist_id, title, type, release_date, is_ignored, cached_at, secondary_types) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
release.RGID, release.ArtistID, release.Title, release.Type, release.ReleaseDate, release.IsIgnored, cachedAt, joinSecondaryTypes(release.SecondaryTypes),
|
||||
release.RGID, release.ArtistID, release.Title, release.Type, release.ReleaseDate, release.IsIgnored, cachedAt, JoinSecondaryTypes(release.SecondaryTypes),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("save external release: %w", err)
|
||||
|
||||
@@ -136,8 +136,8 @@ func SyncArtistDiscography(
|
||||
}
|
||||
|
||||
if _, err := tx.Exec(
|
||||
"INSERT INTO external_releases (rgid, artist_id, title, type, release_date, is_ignored, cached_at) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
ext.RGID, ext.ArtistID, ext.Title, ext.Type, ext.ReleaseDate, ext.IsIgnored, database.FormatCachedAt(ext.CachedAt),
|
||||
"INSERT INTO external_releases (rgid, artist_id, title, type, release_date, is_ignored, cached_at, secondary_types) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
ext.RGID, ext.ArtistID, ext.Title, ext.Type, ext.ReleaseDate, ext.IsIgnored, database.FormatCachedAt(ext.CachedAt), database.JoinSecondaryTypes(ext.SecondaryTypes),
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("sync artist discography: insert release %s: %w", rg.ID, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user