Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
feat(server): support uploading qc result when fme conv is recieved
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Nov 15, 2023
1 parent 11e2bea commit 3e49725
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions server/cmsintegration/cmsintegrationv3/service_fme.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ func receiveResultFromFME(ctx context.Context, s *Services, conf *Config, f fmeR
}
}

// upload qc result
var qcResult string
if f.Status != "error" && f.LogURL != "" {
log.Debugfc(ctx, "cmsintegrationv3: upload qc result: %s", f.LogURL)
var err error
qcResult, err = s.CMS.UploadAsset(ctx, id.ProjectID, f.LogURL)
if err != nil {
return fmt.Errorf("failed to upload qc result: %w", err)
}
}

// update item
convStatus := ConvertionStatus("")
qcStatus := ConvertionStatus("")
Expand All @@ -186,6 +197,7 @@ func receiveResultFromFME(ctx context.Context, s *Services, conf *Config, f fmeR
MaxLOD: maxlodAssetID,
ConvertionStatus: convStatus,
QCStatus: qcStatus,
QCResult: qcResult,
}).CMSItem()

_, err := s.CMS.UpdateItem(ctx, id.ItemID, item.Fields, item.MetadataFields)
Expand Down
8 changes: 7 additions & 1 deletion server/cmsintegration/cmsintegrationv3/service_fme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ func TestReceiveResultFromFME(t *testing.T) {
FeatureType: "bldg",
Type: "qc_conv",
}.String("secret"),
LogURL: "log_ok",
Results: map[string]any{
"_dic": "dic",
"_maxlod": "maxlod",
Expand All @@ -386,6 +387,11 @@ func TestReceiveResultFromFME(t *testing.T) {
Type: "asset",
Value: []string{"bldg"},
},
{
Key: "qc_result",
Type: "asset",
Value: "log_ok",
},
{
Key: "dic",
Type: "asset",
Expand Down Expand Up @@ -418,7 +424,7 @@ func TestReceiveResultFromFME(t *testing.T) {

err := receiveResultFromFME(ctx, s, conf, *res)
assert.NoError(t, err)
assert.Equal(t, []string{"bldg", "dic", "maxlod"}, uploaded)
assert.Equal(t, []string{"bldg", "dic", "maxlod", "log_ok"}, uploaded)

// test case 2: invalid id
r := *res
Expand Down

0 comments on commit 3e49725

Please sign in to comment.