mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-03-15 04:17:30 +01:00
handle single job state queries as simple stringquery
- this will improve index usage for single state queries
This commit is contained in:
@@ -197,11 +197,17 @@ func BuildWhereClause(filter *model.JobFilter, query sq.SelectBuilder) sq.Select
|
||||
query = buildStringCondition("job.cluster_partition", filter.Partition, query)
|
||||
}
|
||||
if filter.State != nil {
|
||||
states := make([]string, len(filter.State))
|
||||
for i, val := range filter.State {
|
||||
states[i] = string(val)
|
||||
if len(filter.State) == 1 {
|
||||
singleStat := string(filter.State[0])
|
||||
singleStateQuery := model.StringInput{Eq: &singleStat}
|
||||
query = buildStringCondition("job.job_state", &singleStateQuery, query)
|
||||
} else {
|
||||
states := make([]string, len(filter.State))
|
||||
for i, val := range filter.State {
|
||||
states[i] = string(val)
|
||||
}
|
||||
query = query.Where(sq.Eq{"job.job_state": states})
|
||||
}
|
||||
query = query.Where(sq.Eq{"job.job_state": states})
|
||||
}
|
||||
if filter.Shared != nil {
|
||||
query = query.Where("job.shared = ?", *filter.Shared)
|
||||
|
||||
Reference in New Issue
Block a user