Add WorkflowRun and AlbumEvent repositories with download cancel support

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/claude-agent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Alexander
2026-05-11 15:53:35 +02:00
parent 7d11b729a5
commit f52e9abb0a
3 changed files with 259 additions and 0 deletions
+20
View File
@@ -86,6 +86,26 @@ func (r *DownloadRepository) SetFailed(ctx context.Context, id string, errorMsg
return nil
}
func (r *DownloadRepository) SetCancelled(ctx context.Context, id string) error {
_, err := r.pool.Exec(ctx,
`UPDATE downloads SET state = 'cancelled', updated_at = NOW() WHERE id = $1`, id,
)
if err != nil {
return fmt.Errorf("setting download cancelled: %w", err)
}
return nil
}
func (r *DownloadRepository) SetCancelledByQbitHash(ctx context.Context, hash string) error {
_, err := r.pool.Exec(ctx,
`UPDATE downloads SET state = 'cancelled', updated_at = NOW() WHERE qbit_hash = $1 AND state NOT IN ('completed', 'failed', 'cancelled')`, hash,
)
if err != nil {
return fmt.Errorf("setting download cancelled by hash: %w", err)
}
return nil
}
func (r *DownloadRepository) GetByAlbumID(ctx context.Context, albumID string) ([]*Download, error) {
rows, err := r.pool.Query(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