From e45ed460c6b545171be748203ca91a3e6ca8b273 Mon Sep 17 00:00:00 2001 From: 0xff-dev Date: Thu, 23 Nov 2023 16:26:19 +0800 Subject: [PATCH] fix: add version count and file count, update gql --- .../go-server/graph/generated/generated.go | 350 ++++++++++-------- .../go-server/graph/generated/models_gen.go | 13 +- .../go-server/graph/impl/dataset.resolvers.go | 2 +- .../go-server/graph/schema/dataset.gql | 46 ++- .../go-server/graph/schema/dataset.graphqls | 7 +- .../graph/schema/versioned_dataset.gql | 46 ++- .../graph/schema/versioned_dataset.graphqls | 11 +- .../go-server/pkg/dataset/dataset.go | 11 + .../pkg/versioneddataset/versioned_dataset.go | 22 +- 9 files changed, 316 insertions(+), 192 deletions(-) diff --git a/graphql-server/go-server/graph/generated/generated.go b/graphql-server/go-server/graph/generated/generated.go index 4e36678a9..d747fbee5 100644 --- a/graphql-server/go-server/graph/generated/generated.go +++ b/graphql-server/go-server/graph/generated/generated.go @@ -104,6 +104,7 @@ type ComplexityRoot struct { DataProcessSupportTypeChildren struct { Description func(childComplexity int) int + Enable func(childComplexity int) int Name func(childComplexity int) int ZhName func(childComplexity int) int } @@ -115,17 +116,17 @@ type ComplexityRoot struct { } Dataset struct { - Annotations func(childComplexity int) int - ContentType func(childComplexity int) int - Creator func(childComplexity int) int - DisplayName func(childComplexity int) int - Field func(childComplexity int) int - Labels func(childComplexity int) int - Name func(childComplexity int) int - Namespace func(childComplexity int) int - UpdateTimestamp func(childComplexity int) int - VersionCount func(childComplexity int) int - Versions func(childComplexity int, input ListVersionedDatasetInput) int + Annotations func(childComplexity int) int + ContentType func(childComplexity int) int + CreationTimestamp func(childComplexity int) int + Creator func(childComplexity int) int + DisplayName func(childComplexity int) int + Field func(childComplexity int) int + Labels func(childComplexity int) int + Name func(childComplexity int) int + Namespace func(childComplexity int) int + UpdateTimestamp func(childComplexity int) int + Versions func(childComplexity int, input ListVersionedDatasetInput) int } DatasetMutation struct { @@ -306,8 +307,8 @@ type ComplexityRoot struct { Creator func(childComplexity int) int DataProcessStatus func(childComplexity int) int Dataset func(childComplexity int) int + Description func(childComplexity int) int DisplayName func(childComplexity int) int - FileCount func(childComplexity int) int Files func(childComplexity int, input *FileFilter) int Labels func(childComplexity int) int Name func(childComplexity int) int @@ -625,6 +626,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.DataProcessSupportTypeChildren.Description(childComplexity), true + case "DataProcessSupportTypeChildren.enable": + if e.complexity.DataProcessSupportTypeChildren.Enable == nil { + break + } + + return e.complexity.DataProcessSupportTypeChildren.Enable(childComplexity), true + case "DataProcessSupportTypeChildren.name": if e.complexity.DataProcessSupportTypeChildren.Name == nil { break @@ -674,6 +682,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Dataset.ContentType(childComplexity), true + case "Dataset.creationTimestamp": + if e.complexity.Dataset.CreationTimestamp == nil { + break + } + + return e.complexity.Dataset.CreationTimestamp(childComplexity), true + case "Dataset.creator": if e.complexity.Dataset.Creator == nil { break @@ -723,13 +738,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Dataset.UpdateTimestamp(childComplexity), true - case "Dataset.versionCount": - if e.complexity.Dataset.VersionCount == nil { - break - } - - return e.complexity.Dataset.VersionCount(childComplexity), true - case "Dataset.versions": if e.complexity.Dataset.Versions == nil { break @@ -1654,19 +1662,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.VersionedDataset.Dataset(childComplexity), true - case "VersionedDataset.displayName": - if e.complexity.VersionedDataset.DisplayName == nil { + case "VersionedDataset.description": + if e.complexity.VersionedDataset.Description == nil { break } - return e.complexity.VersionedDataset.DisplayName(childComplexity), true + return e.complexity.VersionedDataset.Description(childComplexity), true - case "VersionedDataset.fileCount": - if e.complexity.VersionedDataset.FileCount == nil { + case "VersionedDataset.displayName": + if e.complexity.VersionedDataset.DisplayName == nil { break } - return e.complexity.VersionedDataset.FileCount(childComplexity), true + return e.complexity.VersionedDataset.DisplayName(childComplexity), true case "VersionedDataset.files": if e.complexity.VersionedDataset.Files == nil { @@ -2053,6 +2061,7 @@ type DataProcessSupportTypeItem { type DataProcessSupportTypeChildren { name: String! zh_name: String! + enable: String! description: String! } @@ -2111,6 +2120,8 @@ type Dataset { """更新时间, 这里更新指文件同步,或者数据处理完成后,做的更新操作的时间""" updateTimestamp: Time + """创建时间""" + creationTimestamp: Time """数据集类型,文本,图片,视频""" contentType: String! @@ -2123,9 +2134,6 @@ type Dataset { 支持通过标签(somelabel=abc),字段(metadata.name=abc)进行过滤 """ versions(input: ListVersionedDatasetInput!): PaginatedResult! - - """数据集的总版本数量""" - versionCount: Int! } input CreateDatasetInput { @@ -2228,7 +2236,8 @@ extend type Query { extend type Mutation { Dataset: DatasetMutation -}`, BuiltIn: false}, +} +`, BuiltIn: false}, {Name: "../schema/datasource.graphqls", Input: `type Endpoint { url: String authSecret: TypedObjectReference @@ -2683,6 +2692,9 @@ type VersionedDataset { """展示名字, 与metadat.name不一样,这个展示名字是可以用中文的""" displayName: String! + """描述""" + description: String + """所属的数据集""" dataset: TypedObjectReference! @@ -2697,9 +2709,6 @@ type VersionedDataset { """版本名称""" version: String! - """该数据集版本所包含的数据总量""" - fileCount: Int! - """该版本是否已经发布, 0是未发布,1是已经发布""" released: Int! @@ -2816,6 +2825,9 @@ input UpdateVersionedDatasetInput { 如果传递一个空的数组过去,认为是删除全部文件。 """ fileGroups: [FileGroup!] + + """修改数据集版本发布状态""" + released: Int } @@ -2828,7 +2840,7 @@ input DeleteVersionedDatasetInput { input ListVersionedDatasetInput { name: String - namespace: String! + namespace: String displayName: String labelSelector: String fieldSelector: String @@ -4670,6 +4682,50 @@ func (ec *executionContext) fieldContext_DataProcessSupportTypeChildren_zh_name( return fc, nil } +func (ec *executionContext) _DataProcessSupportTypeChildren_enable(ctx context.Context, field graphql.CollectedField, obj *DataProcessSupportTypeChildren) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DataProcessSupportTypeChildren_enable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Enable, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_DataProcessSupportTypeChildren_enable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DataProcessSupportTypeChildren", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _DataProcessSupportTypeChildren_description(ctx context.Context, field graphql.CollectedField, obj *DataProcessSupportTypeChildren) (ret graphql.Marshaler) { fc, err := ec.fieldContext_DataProcessSupportTypeChildren_description(ctx, field) if err != nil { @@ -4842,6 +4898,8 @@ func (ec *executionContext) fieldContext_DataProcessSupportTypeItem_children(ctx return ec.fieldContext_DataProcessSupportTypeChildren_name(ctx, field) case "zh_name": return ec.fieldContext_DataProcessSupportTypeChildren_zh_name(ctx, field) + case "enable": + return ec.fieldContext_DataProcessSupportTypeChildren_enable(ctx, field) case "description": return ec.fieldContext_DataProcessSupportTypeChildren_description(ctx, field) } @@ -5147,6 +5205,47 @@ func (ec *executionContext) fieldContext_Dataset_updateTimestamp(ctx context.Con return fc, nil } +func (ec *executionContext) _Dataset_creationTimestamp(ctx context.Context, field graphql.CollectedField, obj *Dataset) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dataset_creationTimestamp(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreationTimestamp, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*time.Time) + fc.Result = res + return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Dataset_creationTimestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dataset", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Dataset_contentType(ctx context.Context, field graphql.CollectedField, obj *Dataset) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Dataset_contentType(ctx, field) if err != nil { @@ -5299,50 +5398,6 @@ func (ec *executionContext) fieldContext_Dataset_versions(ctx context.Context, f return fc, nil } -func (ec *executionContext) _Dataset_versionCount(ctx context.Context, field graphql.CollectedField, obj *Dataset) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Dataset_versionCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.VersionCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Dataset_versionCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Dataset", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _DatasetMutation_createDataset(ctx context.Context, field graphql.CollectedField, obj *DatasetMutation) (ret graphql.Marshaler) { fc, err := ec.fieldContext_DatasetMutation_createDataset(ctx, field) if err != nil { @@ -5396,14 +5451,14 @@ func (ec *executionContext) fieldContext_DatasetMutation_createDataset(ctx conte return ec.fieldContext_Dataset_displayName(ctx, field) case "updateTimestamp": return ec.fieldContext_Dataset_updateTimestamp(ctx, field) + case "creationTimestamp": + return ec.fieldContext_Dataset_creationTimestamp(ctx, field) case "contentType": return ec.fieldContext_Dataset_contentType(ctx, field) case "field": return ec.fieldContext_Dataset_field(ctx, field) case "versions": return ec.fieldContext_Dataset_versions(ctx, field) - case "versionCount": - return ec.fieldContext_Dataset_versionCount(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Dataset", field.Name) }, @@ -5475,14 +5530,14 @@ func (ec *executionContext) fieldContext_DatasetMutation_updateDataset(ctx conte return ec.fieldContext_Dataset_displayName(ctx, field) case "updateTimestamp": return ec.fieldContext_Dataset_updateTimestamp(ctx, field) + case "creationTimestamp": + return ec.fieldContext_Dataset_creationTimestamp(ctx, field) case "contentType": return ec.fieldContext_Dataset_contentType(ctx, field) case "field": return ec.fieldContext_Dataset_field(ctx, field) case "versions": return ec.fieldContext_Dataset_versions(ctx, field) - case "versionCount": - return ec.fieldContext_Dataset_versionCount(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Dataset", field.Name) }, @@ -5606,14 +5661,14 @@ func (ec *executionContext) fieldContext_DatasetQuery_getDataset(ctx context.Con return ec.fieldContext_Dataset_displayName(ctx, field) case "updateTimestamp": return ec.fieldContext_Dataset_updateTimestamp(ctx, field) + case "creationTimestamp": + return ec.fieldContext_Dataset_creationTimestamp(ctx, field) case "contentType": return ec.fieldContext_Dataset_contentType(ctx, field) case "field": return ec.fieldContext_Dataset_field(ctx, field) case "versions": return ec.fieldContext_Dataset_versions(ctx, field) - case "versionCount": - return ec.fieldContext_Dataset_versionCount(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Dataset", field.Name) }, @@ -11102,6 +11157,47 @@ func (ec *executionContext) fieldContext_VersionedDataset_displayName(ctx contex return fc, nil } +func (ec *executionContext) _VersionedDataset_description(ctx context.Context, field graphql.CollectedField, obj *VersionedDataset) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VersionedDataset_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VersionedDataset_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VersionedDataset", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _VersionedDataset_dataset(ctx context.Context, field graphql.CollectedField, obj *VersionedDataset) (ret graphql.Marshaler) { fc, err := ec.fieldContext_VersionedDataset_dataset(ctx, field) if err != nil { @@ -11352,50 +11448,6 @@ func (ec *executionContext) fieldContext_VersionedDataset_version(ctx context.Co return fc, nil } -func (ec *executionContext) _VersionedDataset_fileCount(ctx context.Context, field graphql.CollectedField, obj *VersionedDataset) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_VersionedDataset_fileCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.FileCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_VersionedDataset_fileCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "VersionedDataset", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _VersionedDataset_released(ctx context.Context, field graphql.CollectedField, obj *VersionedDataset) (ret graphql.Marshaler) { fc, err := ec.fieldContext_VersionedDataset_released(ctx, field) if err != nil { @@ -11573,6 +11625,8 @@ func (ec *executionContext) fieldContext_VersionedDatasetMutation_createVersione return ec.fieldContext_VersionedDataset_creator(ctx, field) case "displayName": return ec.fieldContext_VersionedDataset_displayName(ctx, field) + case "description": + return ec.fieldContext_VersionedDataset_description(ctx, field) case "dataset": return ec.fieldContext_VersionedDataset_dataset(ctx, field) case "updateTimestamp": @@ -11583,8 +11637,6 @@ func (ec *executionContext) fieldContext_VersionedDatasetMutation_createVersione return ec.fieldContext_VersionedDataset_files(ctx, field) case "version": return ec.fieldContext_VersionedDataset_version(ctx, field) - case "fileCount": - return ec.fieldContext_VersionedDataset_fileCount(ctx, field) case "released": return ec.fieldContext_VersionedDataset_released(ctx, field) case "syncStatus": @@ -11660,6 +11712,8 @@ func (ec *executionContext) fieldContext_VersionedDatasetMutation_updateVersione return ec.fieldContext_VersionedDataset_creator(ctx, field) case "displayName": return ec.fieldContext_VersionedDataset_displayName(ctx, field) + case "description": + return ec.fieldContext_VersionedDataset_description(ctx, field) case "dataset": return ec.fieldContext_VersionedDataset_dataset(ctx, field) case "updateTimestamp": @@ -11670,8 +11724,6 @@ func (ec *executionContext) fieldContext_VersionedDatasetMutation_updateVersione return ec.fieldContext_VersionedDataset_files(ctx, field) case "version": return ec.fieldContext_VersionedDataset_version(ctx, field) - case "fileCount": - return ec.fieldContext_VersionedDataset_fileCount(ctx, field) case "released": return ec.fieldContext_VersionedDataset_released(ctx, field) case "syncStatus": @@ -11799,6 +11851,8 @@ func (ec *executionContext) fieldContext_VersionedDatasetQuery_getVersionedDatas return ec.fieldContext_VersionedDataset_creator(ctx, field) case "displayName": return ec.fieldContext_VersionedDataset_displayName(ctx, field) + case "description": + return ec.fieldContext_VersionedDataset_description(ctx, field) case "dataset": return ec.fieldContext_VersionedDataset_dataset(ctx, field) case "updateTimestamp": @@ -11809,8 +11863,6 @@ func (ec *executionContext) fieldContext_VersionedDatasetQuery_getVersionedDatas return ec.fieldContext_VersionedDataset_files(ctx, field) case "version": return ec.fieldContext_VersionedDataset_version(ctx, field) - case "fileCount": - return ec.fieldContext_VersionedDataset_fileCount(ctx, field) case "released": return ec.fieldContext_VersionedDataset_released(ctx, field) case "syncStatus": @@ -15565,7 +15617,7 @@ func (ec *executionContext) unmarshalInputListVersionedDatasetInput(ctx context. var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("namespace")) - data, err := ec.unmarshalNString2string(ctx, v) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } @@ -16101,7 +16153,7 @@ func (ec *executionContext) unmarshalInputUpdateVersionedDatasetInput(ctx contex asMap[k] = v } - fieldsInOrder := [...]string{"name", "namespace", "labels", "annotations", "displayName", "description", "fileGroups"} + fieldsInOrder := [...]string{"name", "namespace", "labels", "annotations", "displayName", "description", "fileGroups", "released"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -16171,6 +16223,15 @@ func (ec *executionContext) unmarshalInputUpdateVersionedDatasetInput(ctx contex return it, err } it.FileGroups = data + case "released": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("released")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Released = data } } @@ -16750,6 +16811,11 @@ func (ec *executionContext) _DataProcessSupportTypeChildren(ctx context.Context, if out.Values[i] == graphql.Null { out.Invalids++ } + case "enable": + out.Values[i] = ec._DataProcessSupportTypeChildren_enable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "description": out.Values[i] = ec._DataProcessSupportTypeChildren_description(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16858,6 +16924,8 @@ func (ec *executionContext) _Dataset(ctx context.Context, sel ast.SelectionSet, } case "updateTimestamp": out.Values[i] = ec._Dataset_updateTimestamp(ctx, field, obj) + case "creationTimestamp": + out.Values[i] = ec._Dataset_creationTimestamp(ctx, field, obj) case "contentType": out.Values[i] = ec._Dataset_contentType(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16901,11 +16969,6 @@ func (ec *executionContext) _Dataset(ctx context.Context, sel ast.SelectionSet, } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "versionCount": - out.Values[i] = ec._Dataset_versionCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -19010,6 +19073,8 @@ func (ec *executionContext) _VersionedDataset(ctx context.Context, sel ast.Selec if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "description": + out.Values[i] = ec._VersionedDataset_description(ctx, field, obj) case "dataset": out.Values[i] = ec._VersionedDataset_dataset(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -19063,11 +19128,6 @@ func (ec *executionContext) _VersionedDataset(ctx context.Context, sel ast.Selec if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "fileCount": - out.Values[i] = ec._VersionedDataset_fileCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } case "released": out.Values[i] = ec._VersionedDataset_released(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/graphql-server/go-server/graph/generated/models_gen.go b/graphql-server/go-server/graph/generated/models_gen.go index d1318294d..fbf77ced6 100644 --- a/graphql-server/go-server/graph/generated/models_gen.go +++ b/graphql-server/go-server/graph/generated/models_gen.go @@ -195,6 +195,7 @@ type DataProcessSupportType struct { type DataProcessSupportTypeChildren struct { Name string `json:"name"` ZhName string `json:"zh_name"` + Enable string `json:"enable"` Description string `json:"description"` } @@ -232,6 +233,8 @@ type Dataset struct { DisplayName string `json:"displayName"` // 更新时间, 这里更新指文件同步,或者数据处理完成后,做的更新操作的时间 UpdateTimestamp *time.Time `json:"updateTimestamp,omitempty"` + // 创建时间 + CreationTimestamp *time.Time `json:"creationTimestamp,omitempty"` // 数据集类型,文本,图片,视频 ContentType string `json:"contentType"` // 应用场景 @@ -240,8 +243,6 @@ type Dataset struct { // 支持对名字,类型的完全匹配过滤。 // 支持通过标签(somelabel=abc),字段(metadata.name=abc)进行过滤 Versions PaginatedResult `json:"versions"` - // 数据集的总版本数量 - VersionCount int `json:"versionCount"` } func (Dataset) IsPageNode() {} @@ -523,7 +524,7 @@ type ListModelInput struct { type ListVersionedDatasetInput struct { Name *string `json:"name,omitempty"` - Namespace string `json:"namespace"` + Namespace *string `json:"namespace,omitempty"` DisplayName *string `json:"displayName,omitempty"` LabelSelector *string `json:"labelSelector,omitempty"` FieldSelector *string `json:"fieldSelector,omitempty"` @@ -690,6 +691,8 @@ type UpdateVersionedDatasetInput struct { // 更新,删除数据集版本中的文件,传递方式于label相同,完全传递。 // 如果传递一个空的数组过去,认为是删除全部文件。 FileGroups []*FileGroup `json:"fileGroups,omitempty"` + // 修改数据集版本发布状态 + Released *int `json:"released,omitempty"` } // VersionedDataset @@ -708,6 +711,8 @@ type VersionedDataset struct { Creator *string `json:"creator,omitempty"` // 展示名字, 与metadat.name不一样,这个展示名字是可以用中文的 DisplayName string `json:"displayName"` + // 描述 + Description *string `json:"description,omitempty"` // 所属的数据集 Dataset TypedObjectReference `json:"dataset"` // 更新时间, 这里更新指文件同步,或者数据处理完成后,做的更新操作的时间 @@ -717,8 +722,6 @@ type VersionedDataset struct { Files PaginatedResult `json:"files"` // 版本名称 Version string `json:"version"` - // 该数据集版本所包含的数据总量 - FileCount int `json:"fileCount"` // 该版本是否已经发布, 0是未发布,1是已经发布 Released int `json:"released"` // 文件的同步状态, Processing或者'' 表示文件正在同步,Succeede 文件同步成功,Failed 存在文件同步失败 diff --git a/graphql-server/go-server/graph/impl/dataset.resolvers.go b/graphql-server/go-server/graph/impl/dataset.resolvers.go index 29df4bc07..da1c333a7 100644 --- a/graphql-server/go-server/graph/impl/dataset.resolvers.go +++ b/graphql-server/go-server/graph/impl/dataset.resolvers.go @@ -24,7 +24,7 @@ func (r *datasetResolver) Versions(ctx context.Context, obj *generated.Dataset, return nil, err } input.Name = nil - input.Namespace = obj.Namespace + input.Namespace = &obj.Namespace labelSelector := fmt.Sprintf("%s=%s", v1alpha1.LabelVersionedDatasetVersionOwner, obj.Name) input.LabelSelector = &labelSelector return versioneddataset.ListVersionedDatasets(ctx, c, &input) diff --git a/graphql-server/go-server/graph/schema/dataset.gql b/graphql-server/go-server/graph/schema/dataset.gql index 37695452d..d85e13edc 100644 --- a/graphql-server/go-server/graph/schema/dataset.gql +++ b/graphql-server/go-server/graph/schema/dataset.gql @@ -1,6 +1,7 @@ query listDatasets($input: ListDatasetInput, $versionsInput: ListVersionedDatasetInput!, $filesInput: FileFilter){ Dataset { - listDatasets(input: $input) { + listDatasets(input: $input) { + totalCount nodes { ... on Dataset { name @@ -8,23 +9,24 @@ query listDatasets($input: ListDatasetInput, $versionsInput: ListVersionedDatase creator displayName updateTimestamp + creationTimestamp contentType field - versionCount versions(input: $versionsInput) { + totalCount nodes { ... on VersionedDataset { name namespace displayName + description + syncStatus + released + dataProcessStatus + updateTimestamp + version files(input: $filesInput) { - nodes { - ... on F { - path - fileType - count - } - } + totalCount } } } @@ -35,7 +37,7 @@ query listDatasets($input: ListDatasetInput, $versionsInput: ListVersionedDatase } } -query getDataset($name: String!, $namespace: String!){ +query getDataset($name: String!, $namespace: String!, $versionsInput: ListVersionedDatasetInput!, $filesInput: FileFilter){ Dataset { getDataset(name:$name, namespace:$namespace) { name @@ -43,15 +45,33 @@ query getDataset($name: String!, $namespace: String!){ creator displayName updateTimestamp + creationTimestamp contentType field - versionCount + versions(input: $versionsInput) { + totalCount + nodes { + ... on VersionedDataset { + name + namespace + displayName + description + syncStatus + released + dataProcessStatus + updateTimestamp + version + files(input: $filesInput) { + totalCount + } + } + } + } } } } - mutation createDataset($input: CreateDatasetInput){ Dataset { createDataset(input: $input){ @@ -75,6 +95,6 @@ mutation updateDataset($input: UpdateDatasetInput){ mutation deleteDatasets($input: DeleteDatasetInput){ Dataset { - deleteDatasets(input: $input) + deleteDatasets(input: $input) } } diff --git a/graphql-server/go-server/graph/schema/dataset.graphqls b/graphql-server/go-server/graph/schema/dataset.graphqls index 832066d2b..e7b80dffb 100644 --- a/graphql-server/go-server/graph/schema/dataset.graphqls +++ b/graphql-server/go-server/graph/schema/dataset.graphqls @@ -35,6 +35,8 @@ type Dataset { """更新时间, 这里更新指文件同步,或者数据处理完成后,做的更新操作的时间""" updateTimestamp: Time + """创建时间""" + creationTimestamp: Time """数据集类型,文本,图片,视频""" contentType: String! @@ -47,9 +49,6 @@ type Dataset { 支持通过标签(somelabel=abc),字段(metadata.name=abc)进行过滤 """ versions(input: ListVersionedDatasetInput!): PaginatedResult! - - """数据集的总版本数量""" - versionCount: Int! } input CreateDatasetInput { @@ -152,4 +151,4 @@ extend type Query { extend type Mutation { Dataset: DatasetMutation -} \ No newline at end of file +} diff --git a/graphql-server/go-server/graph/schema/versioned_dataset.gql b/graphql-server/go-server/graph/schema/versioned_dataset.gql index fcbcf8554..b49743625 100644 --- a/graphql-server/go-server/graph/schema/versioned_dataset.gql +++ b/graphql-server/go-server/graph/schema/versioned_dataset.gql @@ -8,7 +8,6 @@ mutation createVersionedDataset($input:CreateVersionedDatasetInput!){ version updateTimestamp creationTimestamp - fileCount released syncStatus dataProcessStatus @@ -36,9 +35,17 @@ query getVersionedDataset($name: String!, $namespace: String!, $fileInput: FileF getVersionedDataset(name: $name, namespace: $namespace) { name displayName - namespace + description creator + namespace + version + updateTimestamp + creationTimestamp + released + syncStatus + dataProcessStatus files(input: $fileInput){ + totalCount nodes { ... on F { path @@ -55,19 +62,28 @@ query getVersionedDataset($name: String!, $namespace: String!, $fileInput: FileF query listVersionedDatasets($input: ListVersionedDatasetInput!, $fileInput: FileFilter) { VersionedDataset{ listVersionedDatasets(input: $input) { - nodes { - ... on VersionedDataset { - name - displayName - namespace - creator - files(input: $fileInput){ - nodes { - ... on F { - path - time - fileType - count + totalCount + nodes { + ... on VersionedDataset { + name + displayName + description + creator + namespace + version + updateTimestamp + creationTimestamp + released + syncStatus + dataProcessStatus + files(input: $fileInput){ + totalCount + nodes { + ... on F { + path + time + fileType + count } } } diff --git a/graphql-server/go-server/graph/schema/versioned_dataset.graphqls b/graphql-server/go-server/graph/schema/versioned_dataset.graphqls index 6a48e1bb2..90aceb510 100644 --- a/graphql-server/go-server/graph/schema/versioned_dataset.graphqls +++ b/graphql-server/go-server/graph/schema/versioned_dataset.graphqls @@ -22,6 +22,9 @@ type VersionedDataset { """展示名字, 与metadat.name不一样,这个展示名字是可以用中文的""" displayName: String! + """描述""" + description: String + """所属的数据集""" dataset: TypedObjectReference! @@ -36,9 +39,6 @@ type VersionedDataset { """版本名称""" version: String! - """该数据集版本所包含的数据总量""" - fileCount: Int! - """该版本是否已经发布, 0是未发布,1是已经发布""" released: Int! @@ -155,6 +155,9 @@ input UpdateVersionedDatasetInput { 如果传递一个空的数组过去,认为是删除全部文件。 """ fileGroups: [FileGroup!] + + """修改数据集版本发布状态""" + released: Int } @@ -167,7 +170,7 @@ input DeleteVersionedDatasetInput { input ListVersionedDatasetInput { name: String - namespace: String! + namespace: String displayName: String labelSelector: String fieldSelector: String diff --git a/graphql-server/go-server/pkg/dataset/dataset.go b/graphql-server/go-server/pkg/dataset/dataset.go index fa1fcfec7..62da992d5 100644 --- a/graphql-server/go-server/pkg/dataset/dataset.go +++ b/graphql-server/go-server/pkg/dataset/dataset.go @@ -41,6 +41,8 @@ func dataset2model(obj *unstructured.Unstructured) (*generated.Dataset, error) { ds := &generated.Dataset{} ds.Name = obj.GetName() ds.Namespace = obj.GetNamespace() + n := obj.GetCreationTimestamp() + ds.CreationTimestamp = &n.Time if r := obj.GetLabels(); len(r) > 0 { l := make(map[string]any) for k, v := range r { @@ -63,6 +65,15 @@ func dataset2model(obj *unstructured.Unstructured) (*generated.Dataset, error) { ds.DisplayName = dataset.Spec.DisplayName ds.ContentType = dataset.Spec.ContentType ds.Field = &dataset.Spec.Field + first := true + for _, cond := range dataset.Status.Conditions { + if !cond.LastSuccessfulTime.IsZero() { + if first || ds.UpdateTimestamp.Before(cond.LastTransitionTime.Time) { + ds.UpdateTimestamp = &cond.LastTransitionTime.Time + first = false + } + } + } return ds, nil } diff --git a/graphql-server/go-server/pkg/versioneddataset/versioned_dataset.go b/graphql-server/go-server/pkg/versioneddataset/versioned_dataset.go index df8bc2190..4cee07e3b 100644 --- a/graphql-server/go-server/pkg/versioneddataset/versioned_dataset.go +++ b/graphql-server/go-server/pkg/versioneddataset/versioned_dataset.go @@ -69,6 +69,7 @@ func versionedDataset2model(obj *unstructured.Unstructured) (*generated.Versione vds.CreationTimestamp = obj.GetCreationTimestamp().Time vds.Creator = &versioneddataset.Spec.Creator vds.DisplayName = versioneddataset.Spec.DisplayName + vds.Description = &versioneddataset.Spec.Description vds.Dataset = generated.TypedObjectReference{ APIGroup: versioneddataset.Spec.Dataset.APIGroup, Kind: versioneddataset.Spec.Dataset.Kind, @@ -80,17 +81,21 @@ func versionedDataset2model(obj *unstructured.Unstructured) (*generated.Versione vds.Version = versioneddataset.Spec.Version + first := true for _, cond := range versioneddataset.Status.Conditions { if cond.Type == v1alpha1.TypeReady { syncStatus := string(cond.Reason) vds.SyncStatus = &syncStatus } + if !cond.LastTransitionTime.IsZero() { + if first || vds.UpdateTimestamp.Before(cond.LastSuccessfulTime.Time) { + vds.UpdateTimestamp = &cond.LastTransitionTime.Time + first = false + } + } } vds.Released = int(versioneddataset.Spec.Released) - for _, fg := range versioneddataset.Spec.FileGroups { - vds.FileCount += len(fg.Paths) - } return vds, nil } @@ -107,7 +112,7 @@ func VersionFiles(ctx context.Context, c dynamic.Interface, input *generated.Ver objectInfoList := minioutils.ListObjectCompleteInfo(ctx, input.Namespace, prefix, minioClient, -1) result := make([]generated.PageNode, 0) for _, obj := range objectInfoList { - if keyword != "" && strings.Contains(obj.Key, keyword) { + if keyword == "" || strings.Contains(obj.Key, keyword) { result = append(result, generated.F{ Path: obj.Key, FileType: obj.ContentType, @@ -150,7 +155,11 @@ func ListVersionedDatasets(ctx context.Context, c dynamic.Interface, input *gene listOptions.FieldSelector = *input.FieldSelector } } - list, err := c.Resource(versioneddatasetSchem).Namespace(input.Namespace).List(ctx, listOptions) + ns := "default" + if input.Namespace != nil { + ns = *input.Namespace + } + list, err := c.Resource(versioneddatasetSchem).Namespace(ns).List(ctx, listOptions) if err != nil { return nil, err } @@ -245,6 +254,9 @@ func UpdateVersionedDataset(ctx context.Context, c dynamic.Interface, input *gen } obj.SetLabels(l) obj.SetAnnotations(a) + if input.Released != nil { + _ = unstructured.SetNestedField(obj.Object, *input.Released, "spec", "released") + } displayname, _, _ := unstructured.NestedString(obj.Object, "spec", "displayName") description, _, _ := unstructured.NestedString(obj.Object, "spec", "description") if input.DisplayName != "" && input.DisplayName != displayname {