mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 16:05:06 +01:00 
			
		
		
		
	Fix missing model.Aggregate entry, fix status queries and refresh
This commit is contained in:
		| @@ -21,9 +21,10 @@ import ( | |||||||
|  |  | ||||||
| // GraphQL validation should make sure that no unkown values can be specified. | // GraphQL validation should make sure that no unkown values can be specified. | ||||||
| var groupBy2column = map[model.Aggregate]string{ | var groupBy2column = map[model.Aggregate]string{ | ||||||
| 	model.AggregateUser:    "job.hpc_user", | 	model.AggregateUser:       "job.hpc_user", | ||||||
| 	model.AggregateProject: "job.project", | 	model.AggregateProject:    "job.project", | ||||||
| 	model.AggregateCluster: "job.hpc_cluster", | 	model.AggregateCluster:    "job.hpc_cluster", | ||||||
|  | 	model.AggregateSubcluster: "job.subcluster", | ||||||
| } | } | ||||||
|  |  | ||||||
| var sortBy2column = map[model.SortByAggregate]string{ | var sortBy2column = map[model.SortByAggregate]string{ | ||||||
| @@ -176,7 +177,7 @@ func (r *JobRepository) JobsStatsGrouped( | |||||||
| 		var name sql.NullString | 		var name sql.NullString | ||||||
| 		var jobs, users, walltime, nodes, nodeHours, cores, coreHours, accs, accHours sql.NullInt64 | 		var jobs, users, walltime, nodes, nodeHours, cores, coreHours, accs, accHours sql.NullInt64 | ||||||
| 		if err := rows.Scan(&id, &name, &jobs, &users, &walltime, &nodes, &nodeHours, &cores, &coreHours, &accs, &accHours); err != nil { | 		if err := rows.Scan(&id, &name, &jobs, &users, &walltime, &nodes, &nodeHours, &cores, &coreHours, &accs, &accHours); err != nil { | ||||||
| 			cclog.Warn("Error while scanning rows") | 			cclog.Warnf("Error while scanning rows: %s", err.Error()) | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,8 +43,6 @@ | |||||||
|   let cluster = $state(presetCluster); |   let cluster = $state(presetCluster); | ||||||
|   // Histogram |   // Histogram | ||||||
|   let isHistogramSelectionOpen = $state(false); |   let isHistogramSelectionOpen = $state(false); | ||||||
|   let from = $state(new Date(Date.now() - (30 * 24 * 60 * 60 * 1000))); // Simple way to retrigger GQL: Jobs Started last Month |  | ||||||
|   let to = $state(new Date(Date.now())); |  | ||||||
|  |  | ||||||
|   /* Derived */ |   /* Derived */ | ||||||
|   let selectedHistograms = $derived(cluster |   let selectedHistograms = $derived(cluster | ||||||
| @@ -74,11 +72,11 @@ | |||||||
|       } |       } | ||||||
|     `, |     `, | ||||||
|     variables: { |     variables: { | ||||||
|       filter: [{ state: ["running"] }, { cluster: { eq: cluster}}, {startTime: { from, to }}], |       filter: [{ state: ["running"] }, { cluster: { eq: cluster} }], | ||||||
|       selectedHistograms: selectedHistograms, |       selectedHistograms: selectedHistograms | ||||||
|     }, |     }, | ||||||
|  |     requestPolicy: "network-only" | ||||||
|   })); |   })); | ||||||
|  |  | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <!-- Loading indicators & Metric Sleect --> | <!-- Loading indicators & Metric Sleect --> | ||||||
| @@ -96,8 +94,7 @@ | |||||||
|     <Refresher |     <Refresher | ||||||
|       initially={120} |       initially={120} | ||||||
|       onRefresh={() => { |       onRefresh={() => { | ||||||
|         from = new Date(Date.now() - (30 * 24 * 60 * 60 * 1000)); // Triggers GQL |         selectedHistograms = [...$state.snapshot(selectedHistograms)] | ||||||
|         to = new Date(Date.now()); |  | ||||||
|       }} |       }} | ||||||
|     /> |     /> | ||||||
|   </Col> |   </Col> | ||||||
|   | |||||||
| @@ -185,6 +185,7 @@ | |||||||
|       paging: { itemsPerPage: -1, page: 1 }, // Get all: -1 |       paging: { itemsPerPage: -1, page: 1 }, // Get all: -1 | ||||||
|       sorting: { field: "startTime", type: "col", order: "DESC" } |       sorting: { field: "startTime", type: "col", order: "DESC" } | ||||||
|     }, |     }, | ||||||
|  |     requestPolicy: "network-only" | ||||||
|   })); |   })); | ||||||
|  |  | ||||||
|   /* Effects */ |   /* Effects */ | ||||||
| @@ -233,6 +234,10 @@ | |||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|  |   $inspect('From', from) | ||||||
|  |   $inspect('To', to) | ||||||
|  |   $inspect('Query', statusQuery) | ||||||
|  |  | ||||||
|   /* Const Functions */ |   /* Const Functions */ | ||||||
|   const sumUp = (data, subcluster, metric) => |   const sumUp = (data, subcluster, metric) => | ||||||
|     data.reduce( |     data.reduce( | ||||||
| @@ -363,6 +368,7 @@ | |||||||
|     <Refresher |     <Refresher | ||||||
|       initially={120} |       initially={120} | ||||||
|       onRefresh={() => { |       onRefresh={() => { | ||||||
|  |         console.log('Trigger Refresh StatusTab') | ||||||
|         from = new Date(Date.now() - 5 * 60 * 1000); |         from = new Date(Date.now() - 5 * 60 * 1000); | ||||||
|         to = new Date(Date.now()); |         to = new Date(Date.now()); | ||||||
|       }} |       }} | ||||||
|   | |||||||
| @@ -47,8 +47,8 @@ | |||||||
|  |  | ||||||
|   /* State Init */ |   /* State Init */ | ||||||
|   let cluster = $state(presetCluster) |   let cluster = $state(presetCluster) | ||||||
|   let from = $state(new Date(Date.now() - (30 * 24 * 60 * 60 * 1000))); // Simple way to retrigger GQL: Jobs Started last Month |   let pagingState = $state({page: 1, itemsPerPage: 10}) // Top 10 | ||||||
|   let to = $state(new Date(Date.now())); |   let selectedHistograms = $state([]) // Dummy For Refresh  | ||||||
|   let colWidthJobs = $state(0); |   let colWidthJobs = $state(0); | ||||||
|   let colWidthNodes = $state(0); |   let colWidthNodes = $state(0); | ||||||
|   let colWidthAccs = $state(0); |   let colWidthAccs = $state(0); | ||||||
| @@ -84,9 +84,10 @@ | |||||||
|       } |       } | ||||||
|     `, |     `, | ||||||
|     variables: { |     variables: { | ||||||
|       filter: [{ state: ["running"] }, { cluster: { eq: cluster}}, {startTime: { from, to }}], |       filter: [{ state: ["running"] }, { cluster: { eq: cluster} }], | ||||||
|       paging: { itemsPerPage: 10, page: 1 } // Top 10 |       paging: pagingState // Top 10 | ||||||
|     }, |     }, | ||||||
|  |     requestPolicy: "network-only" | ||||||
|   })); |   })); | ||||||
|  |  | ||||||
|   const topNodesQuery = $derived(queryStore({ |   const topNodesQuery = $derived(queryStore({ | ||||||
| @@ -118,9 +119,10 @@ | |||||||
|       } |       } | ||||||
|     `, |     `, | ||||||
|     variables: { |     variables: { | ||||||
|       filter: [{ state: ["running"] }, { cluster: { eq: cluster }}, {startTime: { from, to }}], |       filter: [{ state: ["running"] }, { cluster: { eq: cluster } }], | ||||||
|       paging: { itemsPerPage: 10, page: 1 } // Top 10 |       paging: pagingState | ||||||
|     }, |     }, | ||||||
|  |     requestPolicy: "network-only" | ||||||
|   })); |   })); | ||||||
|  |  | ||||||
|   const topAccsQuery = $derived(queryStore({ |   const topAccsQuery = $derived(queryStore({ | ||||||
| @@ -152,9 +154,10 @@ | |||||||
|       } |       } | ||||||
|     `, |     `, | ||||||
|     variables: { |     variables: { | ||||||
|       filter: [{ state: ["running"] }, { cluster: { eq: cluster }}, {startTime: { from, to }}], |       filter: [{ state: ["running"] }, { cluster: { eq: cluster } }], | ||||||
|       paging: { itemsPerPage: 10, page: 1 } // Top 10 |       paging: pagingState | ||||||
|     }, |     }, | ||||||
|  |     requestPolicy: "network-only" | ||||||
|   })); |   })); | ||||||
|  |  | ||||||
|   // Note: nodeMetrics are requested on configured $timestep resolution |   // Note: nodeMetrics are requested on configured $timestep resolution | ||||||
| @@ -183,10 +186,11 @@ | |||||||
|       } |       } | ||||||
|     `, |     `, | ||||||
|     variables: { |     variables: { | ||||||
|       filter: [{ state: ["running"] }, { cluster: { eq: cluster }}, {startTime: { from, to }}], |       filter: [{ state: ["running"] }, { cluster: { eq: cluster } }], | ||||||
|       selectedHistograms: [], // No Metrics requested for node hardware stats |       selectedHistograms: selectedHistograms, // No Metrics requested for node hardware stats | ||||||
|       numDurationBins: numDurationBins, |       numDurationBins: numDurationBins, | ||||||
|     }, |     }, | ||||||
|  |     requestPolicy: "network-only" | ||||||
|   })); |   })); | ||||||
|  |  | ||||||
|   /* Functions */ |   /* Functions */ | ||||||
| @@ -202,7 +206,6 @@ | |||||||
|       } |       } | ||||||
|     return  c[(c.length + targetIdx) % c.length]; |     return  c[(c.length + targetIdx) % c.length]; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <!-- Refresher and space for other options --> | <!-- Refresher and space for other options --> | ||||||
| @@ -226,8 +229,8 @@ | |||||||
|     <Refresher |     <Refresher | ||||||
|       initially={120} |       initially={120} | ||||||
|       onRefresh={() => { |       onRefresh={() => { | ||||||
|         from = new Date(Date.now() - (30 * 24 * 60 * 60 * 1000)); // Triggers GQL |         pagingState = { page:1, itemsPerPage: 10 }; | ||||||
|         to = new Date(Date.now()); |         selectedHistograms = [...$state.snapshot(selectedHistograms)]; | ||||||
|       }} |       }} | ||||||
|     /> |     /> | ||||||
|   </Col> |   </Col> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user