Skip to content
Snippets Groups Projects
Verified Commit 1427073f authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: add ListJobsForShows

parent 03bb824e
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,33 @@ func (i *jobInventory) ListJobs(showID uint64, offset, limit int) (jobs []*Job)
return
}
func (i *jobInventory) ListJobsForShows(showIDs []uint64, offset int, limit int) (jobs []*Job) {
i.mu.RLock()
defer i.mu.RUnlock()
for _, showID := range showIDs {
ig, exists := i.shows[showID]
if exists {
for _, job := range ig.jobs {
jobs = append(jobs, job)
}
sort.Slice(jobs, func(i, j int) bool { return jobs[i].ID < jobs[j].ID })
}
}
if offset > 0 {
if offset >= len(jobs) {
return []*Job{}
}
jobs = jobs[offset:]
}
if limit >= 0 && limit < len(jobs) {
jobs = jobs[:limit]
}
return
}
func (i *jobInventory) SubscribeJobs(showID uint64) (jobs []*Job, changed <-chan struct{}) {
i.mu.RLock()
defer i.mu.RUnlock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment