MCPcopy Index your code
hub / github.com/riverqueue/river / OrderBy

Method OrderBy

job_list_params.go:368–388  ·  view source on GitHub ↗

OrderBy returns an updated filter set that will sort the results using the specified field and direction. If ordering by FinalizedAt, the States filter will be set to only include finalized job states unless it has already been overridden.

(field JobListOrderByField, direction SortOrder)

Source from the content-addressed store, hash-verified

366// If ordering by FinalizedAt, the States filter will be set to only include
367// finalized job states unless it has already been overridden.
368func (p *JobListParams) OrderBy(field JobListOrderByField, direction SortOrder) *JobListParams {
369 paramsCopy := p.copy()
370 switch field {
371 case JobListOrderByID, JobListOrderByTime, JobListOrderByScheduledAt:
372 paramsCopy.sortField = field
373 case JobListOrderByFinalizedAt:
374 paramsCopy.sortField = field
375 if !p.overrodeState {
376 paramsCopy.states = []rivertype.JobState{
377 rivertype.JobStateCancelled,
378 rivertype.JobStateCompleted,
379 rivertype.JobStateDiscarded,
380 }
381 }
382 default:
383 panic("invalid order by field")
384 }
385 paramsCopy.sortField = field
386 paramsCopy.sortOrder = direction
387 return paramsCopy
388}
389
390// Priorities returns an updated filter set that will only return jobs with the
391// given priorities.

Calls 1

copyMethod · 0.95