diff --git a/internal/repository/job.go b/internal/repository/job.go index 8f00124..b712a86 100644 --- a/internal/repository/job.go +++ b/internal/repository/job.go @@ -10,7 +10,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "strconv" "sync" "time" @@ -18,7 +17,6 @@ import ( "github.com/ClusterCockpit/cc-backend/internal/auth" "github.com/ClusterCockpit/cc-backend/internal/graph/model" "github.com/ClusterCockpit/cc-backend/internal/metricdata" - "github.com/ClusterCockpit/cc-backend/internal/util" "github.com/ClusterCockpit/cc-backend/pkg/log" "github.com/ClusterCockpit/cc-backend/pkg/lrucache" "github.com/ClusterCockpit/cc-backend/pkg/schema" @@ -318,7 +316,7 @@ func (r *JobRepository) FindConcurrentJobs( stopTime = startTime + int64(job.Duration) } - // Add 5m overlap for jobs start time at the end + // Add 200s overlap for jobs start time at the end startTimeTail := startTime + 10 stopTimeTail := stopTime - 200 startTimeFront := startTime + 200 @@ -338,8 +336,7 @@ func (r *JobRepository) FindConcurrentJobs( } items := make([]*model.JobLink, 0, 10) - minStart := int64(math.MaxInt64) - maxStart := int64(0) + queryString := fmt.Sprintf("cluster=%s", job.Cluster) for rows.Next() { var id, jobId, startTime sql.NullInt64 @@ -350,9 +347,7 @@ func (r *JobRepository) FindConcurrentJobs( } if id.Valid { - minStart = util.Min(minStart, startTime.Int64) - maxStart = util.Max(maxStart, startTime.Int64) - + queryString += fmt.Sprintf("&jobId=%d", int(jobId.Int64)) items = append(items, &model.JobLink{ ID: fmt.Sprint(id.Int64), @@ -376,9 +371,7 @@ func (r *JobRepository) FindConcurrentJobs( } if id.Valid { - minStart = util.Min(minStart, startTime.Int64) - maxStart = util.Max(maxStart, startTime.Int64) - + queryString += fmt.Sprintf("&jobId=%d", int(jobId.Int64)) items = append(items, &model.JobLink{ ID: fmt.Sprint(id.Int64), @@ -388,8 +381,6 @@ func (r *JobRepository) FindConcurrentJobs( } cnt := len(items) - queryString := fmt.Sprintf("cluster=%s&startTime=%d-%d&node=%s", - job.Cluster, minStart, maxStart, hostname) return &model.JobLinkResultList{ ListQuery: &queryString, diff --git a/internal/repository/migrations/sqlite3/06_change-config.down.sql b/internal/repository/migrations/sqlite3/06_change-config.down.sql index 74a8299..eccc0ce 100644 --- a/internal/repository/migrations/sqlite3/06_change-config.down.sql +++ b/internal/repository/migrations/sqlite3/06_change-config.down.sql @@ -1,4 +1,10 @@ -ALTER TABLE configuration ADD COLUMN value_new varchar(255); -INSERT INTO configuration (value_new) SELECT value FROM configuration; -ALTER TABLE configuration DROP COLUMN value; -ALTER TABLE configuration RENAME COLUMN value_new TO value; +CREATE TABLE IF NOT EXISTS configuration_new ( +username varchar(255), +confkey varchar(255), +value varchar(255), +PRIMARY KEY (username, confkey), +FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION); + +INSERT INTO configuration_new SELECT * FROM configuration; +DROP TABLE configuration; +ALTER TABLE configuration_new RENAME TO configuration; diff --git a/internal/repository/migrations/sqlite3/06_change-config.up.sql b/internal/repository/migrations/sqlite3/06_change-config.up.sql index 0dae70c..408ce21 100644 --- a/internal/repository/migrations/sqlite3/06_change-config.up.sql +++ b/internal/repository/migrations/sqlite3/06_change-config.up.sql @@ -1,4 +1,10 @@ -ALTER TABLE configuration ADD COLUMN value_new TEXT; -INSERT INTO configuration (value_new) SELECT value FROM configuration; -ALTER TABLE configuration DROP COLUMN value; -ALTER TABLE configuration RENAME COLUMN value_new TO value; +CREATE TABLE IF NOT EXISTS configuration_new ( +username varchar(255), +confkey varchar(255), +value text, +PRIMARY KEY (username, confkey), +FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION); + +INSERT INTO configuration_new SELECT * FROM configuration; +DROP TABLE configuration; +ALTER TABLE configuration_new RENAME TO configuration; diff --git a/internal/repository/query.go b/internal/repository/query.go index d6a9c75..02e5304 100644 --- a/internal/repository/query.go +++ b/internal/repository/query.go @@ -263,11 +263,11 @@ func buildStringCondition(field string, cond *model.StringInput, query sq.Select return query.Where(field+" LIKE ?", fmt.Sprint("%", *cond.Contains, "%")) } if cond.In != nil { - queryUsers := make([]string, len(cond.In)) + queryElements := make([]string, len(cond.In)) for i, val := range cond.In { - queryUsers[i] = val + queryElements[i] = val } - return query.Where(sq.Or{sq.Eq{"job.user": queryUsers}}) + return query.Where(sq.Or{sq.Eq{field: queryElements}}) } return query } diff --git a/internal/routerConfig/routes.go b/internal/routerConfig/routes.go index 3c38a02..351941a 100644 --- a/internal/routerConfig/routes.go +++ b/internal/routerConfig/routes.go @@ -184,6 +184,9 @@ func buildFilterPresets(query url.Values) map[string]interface{} { } } } + if query.Get("node") != "" { + filterPresets["node"] = query.Get("node") + } if query.Get("numNodes") != "" { parts := strings.Split(query.Get("numNodes"), "-") if len(parts) == 2 { @@ -205,7 +208,13 @@ func buildFilterPresets(query url.Values) map[string]interface{} { } } if query.Get("jobId") != "" { - filterPresets["jobId"] = query.Get("jobId") + if len(query["jobId"]) == 1 { + filterPresets["jobId"] = query.Get("jobId") + filterPresets["jobIdMatch"] = "eq" + } else { + filterPresets["jobId"] = query["jobId"] + filterPresets["jobIdMatch"] = "in" + } } if query.Get("arrayJobId") != "" { if num, err := strconv.Atoi(query.Get("arrayJobId")); err == nil { diff --git a/web/frontend/src/Job.root.svelte b/web/frontend/src/Job.root.svelte index 438a277..3d8e58e 100644 --- a/web/frontend/src/Job.root.svelte +++ b/web/frontend/src/Job.root.svelte @@ -27,7 +27,7 @@ resources { hostname, hwthreads, accelerators }, metaData, userData { name, email }, - concurrentJobs { items { id, jobId }, count } + concurrentJobs { items { id, jobId }, count, listQuery } } `) @@ -118,11 +118,12 @@ {/if} {#if $jobMetrics.data && $initq.data} - {#if $initq.data.job.concurrentJobs != null} + {#if $initq.data.job.concurrentJobs.items.length != 0} {#if authlevel > roles.manager}
Concurrent Jobs