remove redundant time parsing

This commit is contained in:
2026-02-11 17:23:39 -08:00
parent fd2e2b0f8a
commit 1478410d0c

View File

@@ -10,6 +10,7 @@ package migrate
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@@ -335,19 +336,24 @@ func (s *trackSource) Err() error {
return nil return nil
} }
batchStart += batchSize // Implements custom JSON unmarshaling to parse the timestamp
func (s *SpotifyTrack) UnmarshalJSON(data []byte) error {
type Alias SpotifyTrack
aux := &struct {
Timestamp string `json:"ts"`
*Alias
}{
Alias: (*Alias)(s),
} }
// Send completion update if err := json.Unmarshal(data, &aux); err != nil {
if progressChan != nil { return err
progressChan <- ProgressUpdate{
CurrentPage: totalBatches,
CompletedPages: totalBatches,
TotalPages: totalBatches,
TracksImported: totalImported,
Status: "completed",
}
} }
ts, err := time.Parse(time.RFC3339Nano, aux.Timestamp)
if err != nil {
return fmt.Errorf("parsing timestamp: %w", err)
}
s.Timestamp = ts
return nil return nil
} }