mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
Load cluster jsons from jobArchive.
This commit is contained in:
parent
3e6fccd273
commit
5c0ada7ec9
@ -3,20 +3,22 @@ package graph
|
|||||||
//go:generate go run github.com/99designs/gqlgen
|
//go:generate go run github.com/99designs/gqlgen
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
|
||||||
"encoding/json"
|
|
||||||
"time"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ClusterCockpit/cc-jobarchive/graph/generated"
|
"github.com/ClusterCockpit/cc-jobarchive/graph/generated"
|
||||||
"github.com/ClusterCockpit/cc-jobarchive/graph/model"
|
"github.com/ClusterCockpit/cc-jobarchive/graph/model"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const jobArchiveDirectory string = "./job-data/"
|
||||||
|
|
||||||
type Resolver struct {
|
type Resolver struct {
|
||||||
DB *sqlx.DB
|
DB *sqlx.DB
|
||||||
}
|
}
|
||||||
@ -104,9 +106,9 @@ func readJobDataFile(jobId string, clusterId *string, startTime *time.Time) ([]b
|
|||||||
lvl1, lvl2 := id/1000, id%1000
|
lvl1, lvl2 := id/1000, id%1000
|
||||||
var filepath string
|
var filepath string
|
||||||
if clusterId == nil {
|
if clusterId == nil {
|
||||||
filepath = fmt.Sprintf("./job-data/%d/%03d/data.json", lvl1, lvl2)
|
filepath = fmt.Sprintf("%s%d/%03d/data.json", jobArchiveDirectory, lvl1, lvl2)
|
||||||
} else {
|
} else {
|
||||||
filepath = fmt.Sprintf("./job-data/%s/%d/%03d/data.json", *clusterId, lvl1, lvl2)
|
filepath = fmt.Sprintf("%s%s/%d/%03d/data.json", jobArchiveDirectory, *clusterId, lvl1, lvl2)
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.ReadFile(filepath)
|
f, err := os.ReadFile(filepath)
|
||||||
@ -303,14 +305,14 @@ func (r *queryResolver) JobsStatistics(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *queryResolver) Clusters(ctx context.Context) ([]*model.Cluster, error) {
|
func (r *queryResolver) Clusters(ctx context.Context) ([]*model.Cluster, error) {
|
||||||
files, err := os.ReadDir("./clusters");
|
files, err := os.ReadDir(jobArchiveDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var clusters []*model.Cluster
|
var clusters []*model.Cluster
|
||||||
for _, entry := range files {
|
for _, entry := range files {
|
||||||
f, err := os.ReadFile("./clusters/" + entry.Name())
|
f, err := os.ReadFile(jobArchiveDirectory + entry.Name() + `/cluster.json`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user