Leftovers
This commit is contained in:
@@ -173,6 +173,19 @@ func (r *DownloadRepository) GetByID(ctx context.Context, id string) (*Download,
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (r *DownloadRepository) GetLatestCompleted(ctx context.Context, albumID string) (*Download, error) {
|
||||
d := &Download{}
|
||||
err := r.pool.QueryRow(ctx,
|
||||
`SELECT id, torrent_id, album_id, format, quality, state, qbit_hash, save_path, error_message, queued_at, started_at, completed_at, created_at, updated_at
|
||||
FROM downloads WHERE album_id = $1 AND state = 'completed'
|
||||
ORDER BY completed_at DESC LIMIT 1`, albumID,
|
||||
).Scan(&d.ID, &d.TorrentID, &d.AlbumID, &d.Format, &d.Quality, &d.State, &d.QbitHash, &d.SavePath, &d.ErrorMessage, &d.QueuedAt, &d.StartedAt, &d.CompletedAt, &d.CreatedAt, &d.UpdatedAt)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting latest completed download: %w", err)
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (r *DownloadRepository) GetByAlbumIDs(ctx context.Context, albumIDs []string) (map[string][]*Download, error) {
|
||||
if len(albumIDs) == 0 {
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user