Skip to content

Commit

Permalink
chore: assorted fixes
Browse files Browse the repository at this point in the history
- remove redundant onboarding service
- remove redundant engagement service
- add pre commit
- fix integration tests
  • Loading branch information
Muchogoc committed Apr 21, 2022
1 parent a04e076 commit 5a6d274
Show file tree
Hide file tree
Showing 26 changed files with 450 additions and 1,694 deletions.
11 changes: 11 additions & 0 deletions .gitguardian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
all-policies: false
api-url: https://api.gitguardian.com
exit-zero: false
paths-ignore:
- "**/README.md"
- doc/*
- LICENSE
- .dockerignore
- .gitignore
show-secrets: false
verbose: false
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Options for analysis running.
run:
skip-dirs:
- pkg/clinical/presentation/graph/
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/gitguardian/ggshield
rev: v1.11.0
hooks:
- id: ggshield
stages: [commit]
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.0
hooks:
- id: golangci-lint # install https://golangci-lint.run/usage/install/#local-installation
12 changes: 0 additions & 12 deletions deps.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
staging:
- depName: onboarding
depRootDomain: https://onboarding-testing.savannahghi.org
- depName: engagement
depRootDomain: https://engagement-testing.savannahghi.org
- depName: mycarehub
depRootDomain: https://mycarehub-staging.savannahghi.org
testing:
- depName: onboarding
depRootDomain: https://onboarding-testing.savannahghi.org
- depName: engagement
depRootDomain: https://engagement-testing.savannahghi.org
- depName: mycarehub
depRootDomain: https://mycarehub-testing.savannahghi.org
production:
- depName: onboarding
depRootDomain: https://onboarding-prod.savannahghi.org
- depName: engagement
depRootDomain: https://engagement-prod.savannahghi.org
- depName: mycarehub
depRootDomain: https://mycarehub-prod.savannahghi.org
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ require (
cloud.google.com/go/profiler v0.2.0 // indirect
cloud.google.com/go/pubsub v1.19.0
cloud.google.com/go/trace v1.2.0 // indirect
contrib.go.opencensus.io/exporter/stackdriver v0.13.8 // indirect
firebase.google.com/go v3.13.0+incompatible
github.com/99designs/gqlgen v0.13.0
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/aws/aws-sdk-go v1.40.0 // indirect
github.com/brianvoe/gofakeit v3.18.0+incompatible
github.com/casbin/casbin/v2 v2.37.2
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.3.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imroc/req v0.3.0
github.com/kr/pretty v0.3.0 // indirect
github.com/labstack/gommon v0.3.0
github.com/mitchellh/mapstructure v1.4.2
github.com/pkg/errors v0.9.1
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rs/xid v1.3.0
github.com/savannahghi/converterandformatter v0.0.11
Expand All @@ -31,7 +33,6 @@ require (
github.com/savannahghi/feedlib v0.0.6
github.com/savannahghi/firebasetools v0.0.15
github.com/savannahghi/interserviceclient v0.0.18
github.com/savannahghi/onboarding v0.0.22
github.com/savannahghi/profileutils v0.0.17
github.com/savannahghi/pubsubtools v0.0.2
github.com/savannahghi/scalarutils v0.0.4
Expand Down
42 changes: 3 additions & 39 deletions go.sum

Large diffs are not rendered by default.

13 changes: 4 additions & 9 deletions pkg/clinical/application/common/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/asaskevich/govalidator"
"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/domain"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure"

fb "github.com/savannahghi/clinical/pkg/clinical/infrastructure/datastore/firebase"
"github.com/savannahghi/converterandformatter"
Expand Down Expand Up @@ -365,24 +364,20 @@ func ContactsToContactPoint(
contactUse := domain.ContactPointUseEnumHome
emailSystem := domain.ContactPointSystemEnumEmail
phoneSystem := domain.ContactPointSystemEnumPhone
engagement := infrastructure.NewInfrastructureInteractor()

for _, phone := range phones {

isVerified, normalized, err := engagement.Engagement.VerifyOTP(
ctx, phone.Msisdn, phone.VerificationCode)
normalized, err := converterandformatter.NormalizeMSISDN(phone.Msisdn)
if err != nil {
return nil, fmt.Errorf("invalid phone: %w", err)
}
if !isVerified {
return nil, fmt.Errorf("invalid OTP")
return nil, fmt.Errorf("unable to normalize phone number: %w", err)
}

phoneContact := &domain.FHIRContactPoint{
System: &phoneSystem,
Use: &contactUse,
Rank: &rank,
Period: common.DefaultPeriod(),
Value: &normalized,
Value: normalized,
}
output = append(output, phoneContact)
rank++
Expand Down
16 changes: 0 additions & 16 deletions pkg/clinical/application/dto/input.go
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
package dto

import (
"github.com/savannahghi/enumutils"
"github.com/savannahghi/scalarutils"
)

//RegisterUserPayload is the payload used to pass user details to onboarding service
type RegisterUserPayload struct {
UID string `json:"uid,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Gender enumutils.Gender `json:"gender,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
Email string `json:"email,omitempty"`
DateOfBirth scalarutils.Date `json:"dateOfBirth,omitempty"`
}
8 changes: 4 additions & 4 deletions pkg/clinical/infrastructure/datastore/fhir/dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestMain(m *testing.M) {
}
for _, collection := range collections {
ref := fsc.Collection(collection)
firebasetools.DeleteCollection(ctx, fsc, ref, 10)
_ = firebasetools.DeleteCollection(ctx, fsc, ref, 10)
}
}

Expand Down Expand Up @@ -133,7 +133,7 @@ func TestRepository_CreateDataset(t *testing.T) {
err.Error(),
"googleapi: Error 409: already exists",
) {
t.Errorf("unexpected error: %w", err)
t.Errorf("unexpected error: %v", err)
return
}
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestRepository_GetDataset(t *testing.T) {
err.Error(),
"googleapi: Error 404: does not exist exists",
) {
t.Errorf("unexpected error: %w", err)
t.Errorf("unexpected error: %v", err)
return
}
assert.NotNil(t, got)
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestRepository_CreateFHIRStore(t *testing.T) {
err.Error(),
"googleapi: Error 409: already exists",
) {
t.Errorf("unexpected error: %w", err)
t.Errorf("unexpected error: %v", err)
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestMain(m *testing.M) {
}
for _, collection := range collections {
ref := fsc.Collection(collection)
firebasetools.DeleteCollection(ctx, fsc, ref, 10)
_ = firebasetools.DeleteCollection(ctx, fsc, ref, 10)
}
}

Expand Down
12 changes: 0 additions & 12 deletions pkg/clinical/infrastructure/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package infrastructure
import (
"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/application/extensions"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/engagement"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/mycarehub"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/onboarding"
"github.com/savannahghi/clinical/pkg/clinical/infrastructure/services/openconceptlab"
"github.com/savannahghi/firebasetools"
)
Expand All @@ -14,8 +12,6 @@ import (
type Infrastructure struct {
FHIRRepo FHIRRepository
FirestoreRepo Repository
Engagement engagement.ServiceEngagement
Onboarding onboarding.ServiceOnboarding
OpenConceptLab openconceptlab.ServiceOCL
BaseExtension extensions.BaseExtension
MyCareHub mycarehub.IServiceMyCareHub
Expand All @@ -26,14 +22,8 @@ func NewInfrastructureInteractor() Infrastructure {
baseExtension := extensions.NewBaseExtensionImpl(&firebasetools.FirebaseClient{})
fhirRepository := NewFHIRService()

engagementClient := common.NewInterServiceClient("engagement", baseExtension)
engagement := engagement.NewServiceEngagementImpl(engagementClient, baseExtension)

firestoreDB := NewDBService()

onboardingClient := common.NewInterServiceClient("onboarding", baseExtension)
onboarding := onboarding.NewServiceOnboardingImpl(onboardingClient, baseExtension)

myCareHubClient := common.NewInterServiceClient("mycarehub", baseExtension)
mycarehub := mycarehub.NewServiceMyCareHub(myCareHubClient, baseExtension)

Expand All @@ -42,8 +32,6 @@ func NewInfrastructureInteractor() Infrastructure {
return Infrastructure{
fhirRepository,
firestoreDB,
engagement,
onboarding,
openconceptlab,
baseExtension,
mycarehub,
Expand Down

0 comments on commit 5a6d274

Please sign in to comment.