Skip to content

Commit

Permalink
Merge pull request #137 from onattech/Pipeline_Struct_Add_JSON
Browse files Browse the repository at this point in the history
json field added to pipelines table for the original flows json.
  • Loading branch information
saul-data authored Feb 28, 2022
2 parents d663201 + 8067807 commit 61bc9ec
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/mainapp/database/models/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type Pipelines struct {
Current string `json:"current"` //current history
WorkerGroup string `json:"worker_group"`
Meta datatypes.JSON `json:"meta"`
UpdateLock bool `gorm:"default:false;" json:"name"`
Json datatypes.JSON `json:"json"`
UpdateLock bool `gorm:"default:false;" json:"update_lock"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions app/mainapp/graphql/private/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/mainapp/graphql/private/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/mainapp/graphql/private/resolvers/pipelines.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ input PipelineEdgesInput {
input PipelineFlowInput {
nodesInput: [PipelineNodesInput!]!
edgesInput: [PipelineEdgesInput!]!
json: Any!
}

# ----- Get flow
Expand Down
21 changes: 20 additions & 1 deletion app/mainapp/graphql/private/resolvers/pipelines.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package privateresolvers

import (
"context"
"dataplane/mainapp/auth_permissions"
permissions "dataplane/mainapp/auth_permissions"
"dataplane/mainapp/config"
"dataplane/mainapp/database"
"dataplane/mainapp/database/models"
Expand Down Expand Up @@ -269,6 +269,25 @@ func (r *mutationResolver) AddUpdatePipelineFlow(ctx context.Context, input *pri
return "", errors.New("add pipeline flow node database error")
}

// Records original JSON information in database
JSON, err := json.Marshal(input.JSON)
if err != nil {
logging.PrintSecretsRedact(err)
}

e := models.Pipelines{
Json: JSON,
}

err = database.DBConn.Where("pipeline_id = ?", pipelineID).Updates(&e).Error

if err != nil {
if os.Getenv("debug") == "true" {
logging.PrintSecretsRedact(err)
}
return "", errors.New("Update pipeline database error.")
}

// ----- unlock the pipeline
err = database.DBConn.Model(&models.Pipelines{}).Where("pipeline_id = ?", pipelineID).Update("update_lock", false).Error
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package privateresolvers

import (
"context"
permissions "dataplane/mainapp/auth_permissions"
"dataplane/mainapp/auth_permissions"
"dataplane/mainapp/config"
"dataplane/mainapp/database"
"dataplane/mainapp/database/models"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Flow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,5 +459,5 @@ function prepareInputForBackend(input) {
}
}

return { nodesInput, edgesInput };
return { nodesInput, edgesInput, json: input };
}

0 comments on commit 61bc9ec

Please sign in to comment.