動画を確認画面つきで複数削除できるようにする(ステップ13)
This commit is contained in:
@@ -201,6 +201,39 @@ func (s *Store) ListSucceededJobsBySeries(ctx context.Context, seriesID string)
|
||||
return jobs, rows.Err()
|
||||
}
|
||||
|
||||
func (s *Store) ListSucceededJobsByIDs(ctx context.Context, ids []int64) ([]Job, error) {
|
||||
if len(ids) == 0 {
|
||||
return []Job{}, nil
|
||||
}
|
||||
return s.listSucceededJobs(ctx, `id = ANY($1)`, ids)
|
||||
}
|
||||
|
||||
func (s *Store) ListSucceededJobsBySeriesIDs(ctx context.Context, seriesIDs []string) ([]Job, error) {
|
||||
if len(seriesIDs) == 0 {
|
||||
return []Job{}, nil
|
||||
}
|
||||
return s.listSucceededJobs(ctx, `series_id = ANY($1)`, seriesIDs)
|
||||
}
|
||||
|
||||
func (s *Store) listSucceededJobs(ctx context.Context, condition string, value any) ([]Job, error) {
|
||||
rows, err := s.pool.Query(ctx, `SELECT `+jobColumns+` FROM download_jobs
|
||||
WHERE status='succeeded' AND `+condition+`
|
||||
ORDER BY id`, value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var jobs []Job
|
||||
for rows.Next() {
|
||||
job, err := scanJob(rows)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
jobs = append(jobs, job)
|
||||
}
|
||||
return jobs, rows.Err()
|
||||
}
|
||||
|
||||
func (s *Store) DeleteSucceededJob(ctx context.Context, id int64) error {
|
||||
tag, err := s.pool.Exec(ctx, `DELETE FROM download_jobs WHERE id=$1 AND status='succeeded'`, id)
|
||||
return transitionResult(tag.RowsAffected(), err)
|
||||
|
||||
Reference in New Issue
Block a user