Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nourbalaha committed Dec 23, 2024
1 parent d2f3636 commit e80cf07
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
env:
BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
echo "sha_short=$(git rev-parse --short HEAD))" >> "$GITHUB_OUTPUT"
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
if [[ "$BRANCH" = "release" ]]; then
TAG=$(git tag --points-at HEAD)
if [[ ! -z "$TAG" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion server/internal/infrastructure/gcp/taskrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func decompressAsset(ctx context.Context, p task.Payload, conf *TaskConfig) erro
}

func copy(ctx context.Context, p task.Payload, conf *TaskConfig) error {
if p.Copy == nil {
if !p.Copy.Validate() {
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion server/internal/usecase/interactor/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ func (i Model) copyMetaSchema(ctx context.Context, oldMetaSchemaId id.SchemaID,
}

func (i Model) copyItems(ctx context.Context, oldSchemaID, newSchemaID id.SchemaID, newModelID id.ModelID) error {
collection := "item"
filter, err := json.Marshal(bson.M{"schema": oldSchemaID.String()})
if err != nil {
return err
Expand All @@ -434,7 +435,7 @@ func (i Model) copyItems(ctx context.Context, oldSchemaID, newSchemaID id.Schema
if err != nil {
return err
}
return i.triggerCopyEvent(ctx, "item", string(filter), string(changes))
return i.triggerCopyEvent(ctx, collection, string(filter), string(changes))
}

func (i Model) triggerCopyEvent(ctx context.Context, collection, filter, changes string) error {
Expand Down
4 changes: 4 additions & 0 deletions server/pkg/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (p *CopyPayload) Payload() Payload {
}
}

func (p *CopyPayload) Validate() bool {
return p != nil && p.Changes != "" && p.Collection != "" && p.Filter != ""
}

type Changes map[string]Change
type Change struct {
Type ChangeType
Expand Down

0 comments on commit e80cf07

Please sign in to comment.