Fix path errors. Fix data schema.

This commit is contained in:
Jan Eitzinger 2021-03-31 08:50:53 +02:00
parent b7970585ea
commit 9940c44f2b
7 changed files with 4397 additions and 17 deletions

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/moebiusband/cc-jobarchive module github.com/ClusterCockpit/cc-jobarchive
go 1.15 go 1.15

View File

@ -35,7 +35,7 @@ resolver:
# gqlgen will search for any type names in the schema in these go packages # gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them. # if they match it will use them, otherwise it will generate them.
autobind: autobind:
- "fossil.moebiusband.org/jobaccounting-backend/graph/model" - "github.com/ClusterCockpit/cc-jobarchive/graph/model"
# This section declares type mapping between the GraphQL and go type systems # This section declares type mapping between the GraphQL and go type systems
# #
@ -55,6 +55,6 @@ models:
- github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32 - github.com/99designs/gqlgen/graphql.Int32
Job: Job:
model: "fossil.moebiusband.org/jobaccounting-backend/graph/model.Job" model: "github.com/ClusterCockpit/cc-jobarchive/graph/model.Job"
Timestamp: Timestamp:
model: "fossil.moebiusband.org/jobaccounting-backend/graph/model.Timestamp" model: "github.com/ClusterCockpit/cc-jobarchive/graph/model.Timestamp"

4244
graph/generated/generated.go Normal file

File diff suppressed because it is too large Load Diff

142
graph/model/models_gen.go Normal file
View File

@ -0,0 +1,142 @@
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package model
import (
"fmt"
"io"
"strconv"
"time"
)
type AddJobInput struct {
JobID string `json:"jobId"`
UserID string `json:"userId"`
ProjectID string `json:"projectId"`
ClusterID string `json:"clusterId"`
StartTime time.Time `json:"startTime"`
Duration int `json:"duration"`
NumNodes int `json:"numNodes"`
}
type FloatRange struct {
From float64 `json:"from"`
To float64 `json:"to"`
}
type HistoPoint struct {
Count int `json:"count"`
Value int `json:"value"`
}
type IntRange struct {
From int `json:"from"`
To int `json:"to"`
}
type JobFilter struct {
JobID *StringInput `json:"jobId"`
UserID *StringInput `json:"userId"`
ProjectID *StringInput `json:"projectId"`
ClusterID *StringInput `json:"clusterId"`
Duration *IntRange `json:"duration"`
NumNodes *IntRange `json:"numNodes"`
StartTime *TimeRange `json:"startTime"`
HasProfile *bool `json:"hasProfile"`
}
type JobFilterList struct {
List []*JobFilter `json:"list"`
}
type JobResultList struct {
Items []*Job `json:"items"`
Offset *int `json:"offset"`
Limit *int `json:"limit"`
Count *int `json:"count"`
}
type JobsStatistics struct {
TotalJobs int `json:"totalJobs"`
ShortJobs int `json:"shortJobs"`
TotalWalltime int `json:"totalWalltime"`
TotalCoreHours int `json:"totalCoreHours"`
HistWalltime []*HistoPoint `json:"histWalltime"`
HistNumNodes []*HistoPoint `json:"histNumNodes"`
}
type OrderByInput struct {
Field string `json:"field"`
Order *SortDirectionEnum `json:"order"`
}
type PageRequest struct {
ItemsPerPage *int `json:"itemsPerPage"`
Page *int `json:"page"`
}
type StartJobInput struct {
JobID string `json:"jobId"`
UserID string `json:"userId"`
ProjectID string `json:"projectId"`
ClusterID string `json:"clusterId"`
StartTime time.Time `json:"startTime"`
NumNodes int `json:"numNodes"`
}
type StopJobInput struct {
StopTime time.Time `json:"stopTime"`
}
type StringInput struct {
Eq *string `json:"eq"`
Contains *string `json:"contains"`
StartsWith *string `json:"startsWith"`
EndsWith *string `json:"endsWith"`
}
type TimeRange struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
}
type SortDirectionEnum string
const (
SortDirectionEnumDesc SortDirectionEnum = "DESC"
SortDirectionEnumAsc SortDirectionEnum = "ASC"
)
var AllSortDirectionEnum = []SortDirectionEnum{
SortDirectionEnumDesc,
SortDirectionEnumAsc,
}
func (e SortDirectionEnum) IsValid() bool {
switch e {
case SortDirectionEnumDesc, SortDirectionEnumAsc:
return true
}
return false
}
func (e SortDirectionEnum) String() string {
return string(e)
}
func (e *SortDirectionEnum) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = SortDirectionEnum(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid SortDirectionEnum", str)
}
return nil
}
func (e SortDirectionEnum) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}

View File

@ -7,8 +7,8 @@ import (
"log" "log"
"strings" "strings"
"fossil.moebiusband.org/jobaccounting-backend/graph/generated" "github.com/ClusterCockpit/cc-jobarchive/graph/generated"
"fossil.moebiusband.org/jobaccounting-backend/graph/model" "github.com/ClusterCockpit/cc-jobarchive/graph/model"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
) )
@ -113,8 +113,8 @@ func (r *queryResolver) Jobs(
var qc, ob string var qc, ob string
if page != nil { if page != nil {
limit = *page.Limit limit = *page.ItemsPerPage
offset = *page.Offset offset = (*page.Page - 1) * limit
} else { } else {
limit = 20 limit = 20
offset = 0 offset = 0

View File

@ -15,12 +15,6 @@ type Query {
jobsStatistics(filter: JobFilterList): JobsStatistics! jobsStatistics(filter: JobFilterList): JobsStatistics!
} }
type Mutation {
startJob(input: StartJobInput!): Job!
stopJob(input: StopJobInput!): Job!
addJob(input: AddJobInput!): Job!
}
input StartJobInput { input StartJobInput {
jobId: String! jobId: String!
userId: String! userId: String!
@ -114,7 +108,7 @@ type JobsStatistics {
} }
input PageRequest { input PageRequest {
itensPerPage: Int itemsPerPage: Int
page: Int page: Int
} }

View File

@ -7,12 +7,12 @@ import (
"github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground" "github.com/99designs/gqlgen/graphql/playground"
"github.com/ClusterCockpit/cc-jobarchive/graph"
"github.com/ClusterCockpit/cc-jobarchive/graph/generated"
"github.com/gorilla/handlers" "github.com/gorilla/handlers"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/moebiusband/cc-jobarchive/generated"
"github.com/moebiusband/cc-jobarchive/graph"
) )
const defaultPort = "8080" const defaultPort = "8080"