mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +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
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"os"
|
||||
"strconv"
|
||||
"encoding/json"
|
||||
"time"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-jobarchive/graph/generated"
|
||||
"github.com/ClusterCockpit/cc-jobarchive/graph/model"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
const jobArchiveDirectory string = "./job-data/"
|
||||
|
||||
type Resolver struct {
|
||||
DB *sqlx.DB
|
||||
}
|
||||
@ -104,9 +106,9 @@ func readJobDataFile(jobId string, clusterId *string, startTime *time.Time) ([]b
|
||||
lvl1, lvl2 := id/1000, id%1000
|
||||
var filepath string
|
||||
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 {
|
||||
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)
|
||||
@ -303,14 +305,14 @@ func (r *queryResolver) JobsStatistics(
|
||||
}
|
||||
|
||||
func (r *queryResolver) Clusters(ctx context.Context) ([]*model.Cluster, error) {
|
||||
files, err := os.ReadDir("./clusters");
|
||||
files, err := os.ReadDir(jobArchiveDirectory)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var clusters []*model.Cluster
|
||||
for _, entry := range files {
|
||||
f, err := os.ReadFile("./clusters/" + entry.Name())
|
||||
f, err := os.ReadFile(jobArchiveDirectory + entry.Name() + `/cluster.json`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user