Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix-ci-test #1077

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/ci_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: server/go.sum
- name: test
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
run: |
go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m -json
| tee ./go-test.out
| go run github.com/mfridman/tparse -all
env:
REEARTH_DB: mongodb://localhost
working-directory: server
- name: Add job summary
if: always()
run: |
go install github.com/mfridman/tparse@latest &&
go run github.com/mfridman/tparse -file ./go-test.out -format markdown >> $GITHUB_STEP_SUMMARY
working-directory: server
- name: Send coverage report
uses: codecov/codecov-action@v2
with:
Expand Down
183 changes: 183 additions & 0 deletions server/internal/usecase/interactor/nlslayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type NLSLayer struct {
commonSceneLock
nlslayerRepo repo.NLSLayer
sceneLockRepo repo.SceneLock
projectRepo repo.Project
sceneRepo repo.Scene
propertyRepo repo.Property
pluginRepo repo.Plugin
transaction usecasex.Transaction
Expand All @@ -32,6 +34,8 @@ func NewNLSLayer(r *repo.Container) interfaces.NLSLayer {
commonSceneLock: commonSceneLock{sceneLockRepo: r.SceneLock},
nlslayerRepo: r.NLSLayer,
sceneLockRepo: r.SceneLock,
projectRepo: r.Project,
sceneRepo: r.Scene,
propertyRepo: r.Property,
pluginRepo: r.Plugin,
transaction: r.Transaction,
Expand Down Expand Up @@ -102,6 +106,17 @@ func (i *NLSLayer) AddLayerSimple(ctx context.Context, inp interfaces.AddNLSLaye
return nil, err
}

s, err := i.sceneRepo.FindByID(ctx, *inp.SceneID.Ref())
if err != nil {
return nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nil, err
}

tx.Commit()
return layerSimple, nil
}
Expand Down Expand Up @@ -181,6 +196,20 @@ func (i *NLSLayer) Remove(ctx context.Context, lid id.NLSLayerID, operator *usec
return lid, nil, err
}

s, err := i.sceneRepo.FindByID(ctx, l.Scene())
if err != nil {
return lid, nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return lid, nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return lid, nil, err
}

tx.Commit()
return lid, parentLayer, nil
}
Expand Down Expand Up @@ -223,6 +252,20 @@ func (i *NLSLayer) Update(ctx context.Context, inp interfaces.UpdateNLSLayerInpu
return nil, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nil, err
}

tx.Commit()
return layer, nil
}
Expand Down Expand Up @@ -275,6 +318,20 @@ func (i *NLSLayer) CreateNLSInfobox(ctx context.Context, lid id.NLSLayerID, oper
return nil, err
}

s, err := i.sceneRepo.FindByID(ctx, l.Scene())
if err != nil {
return nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nil, err
}

tx.Commit()
return l, nil
}
Expand Down Expand Up @@ -323,6 +380,20 @@ func (i *NLSLayer) RemoveNLSInfobox(ctx context.Context, layerID id.NLSLayerID,
return nil, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nil, err
}

tx.Commit()
return layer, nil
}
Expand Down Expand Up @@ -421,6 +492,20 @@ func (i *NLSLayer) AddNLSInfoboxBlock(ctx context.Context, inp interfaces.AddNLS
return nil, nil, err
}

s, err := i.sceneRepo.FindByID(ctx, l.Scene())
if err != nil {
return nil, nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nil, nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nil, nil, err
}

tx.Commit()
return block, l, err
}
Expand Down Expand Up @@ -463,6 +548,20 @@ func (i *NLSLayer) MoveNLSInfoboxBlock(ctx context.Context, inp interfaces.MoveN
return inp.InfoboxBlockID, nil, -1, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return inp.InfoboxBlockID, nil, -1, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return inp.InfoboxBlockID, nil, -1, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return inp.InfoboxBlockID, nil, -1, err
}

tx.Commit()
return inp.InfoboxBlockID, layer, inp.Index, err
}
Expand Down Expand Up @@ -505,6 +604,20 @@ func (i *NLSLayer) RemoveNLSInfoboxBlock(ctx context.Context, inp interfaces.Rem
return inp.InfoboxBlockID, nil, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return inp.InfoboxBlockID, nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return inp.InfoboxBlockID, nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return inp.InfoboxBlockID, nil, err
}

tx.Commit()
return inp.InfoboxBlockID, layer, err
}
Expand Down Expand Up @@ -537,6 +650,20 @@ func (i *NLSLayer) Duplicate(ctx context.Context, lid id.NLSLayerID, operator *u
return nil, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nil, err
}

tx.Commit()
return duplicatedLayer, nil
}
Expand Down Expand Up @@ -580,6 +707,20 @@ func (i *NLSLayer) AddCustomProperties(ctx context.Context, inp interfaces.AddCu
return nil, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return nil, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nil, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nil, err
}

tx.Commit()
return layer, nil
}
Expand Down Expand Up @@ -641,6 +782,20 @@ func (i *NLSLayer) AddGeoJSONFeature(ctx context.Context, inp interfaces.AddNLSL
return nlslayer.Feature{}, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return nlslayer.Feature{}, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nlslayer.Feature{}, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nlslayer.Feature{}, err
}

tx.Commit()
return *feature, nil
}
Expand Down Expand Up @@ -693,6 +848,20 @@ func (i *NLSLayer) UpdateGeoJSONFeature(ctx context.Context, inp interfaces.Upda
return nlslayer.Feature{}, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return nlslayer.Feature{}, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return nlslayer.Feature{}, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return nlslayer.Feature{}, err
}

tx.Commit()
return updatedFeature, nil
}
Expand Down Expand Up @@ -729,6 +898,20 @@ func (i *NLSLayer) DeleteGeoJSONFeature(ctx context.Context, inp interfaces.Dele
return id.FeatureID{}, err
}

s, err := i.sceneRepo.FindByID(ctx, layer.Scene())
if err != nil {
return id.FeatureID{}, err
}

prj, err := i.projectRepo.FindByID(ctx, s.Project())
if err != nil {
return id.FeatureID{}, err
}

if err := updateProjectUpdatedAt(ctx, prj, i.projectRepo); err != nil {
return id.FeatureID{}, err
}

tx.Commit()
return inp.FeatureID, nil
}
1 change: 1 addition & 0 deletions server/internal/usecase/interactor/nlslayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestAddCustomProperties(t *testing.T) {
ctx := context.Background()

db := memory.New()

scene, _ := scene.New().NewID().Workspace(accountdomain.NewWorkspaceID()).Project(id.NewProjectID()).RootLayer(id.NewLayerID()).Build()
_ = db.Scene.Save(ctx, scene)
il := NewNLSLayer(db)
Expand Down
10 changes: 10 additions & 0 deletions server/internal/usecase/interactor/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,13 @@ func (i *Project) Delete(ctx context.Context, projectID id.ProjectID, operator *
tx.Commit()
return nil
}

func updateProjectUpdatedAt(ctx context.Context, prj *project.Project, r repo.Project) error {
currentTime := time.Now().UTC()
prj.SetUpdatedAt(currentTime)

if err := r.Save(ctx, prj); err != nil {
return err
}
return nil
}
Loading
Loading