Skip to content

Commit

Permalink
Merge branch 'main' into rename-default-branch-to-main
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccar authored Feb 24, 2023
2 parents b7a825d + bbbb3ce commit a61d810
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### What is the context of this PR?
Describe what you have changed and why, link to other PRs or Issues as appropriate.

### How to review
### How to review
Describe the steps required to test the changes (include screenshots if appropriate).
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
docker-push:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Install Go
uses: actions/setup-go@v3
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Build
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo
docker-push:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Tag
Expand Down
45 changes: 30 additions & 15 deletions authentication/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,26 @@ type Metadata struct {
func isSurveyMetadata(key string) bool {
switch key {
case
"case_ref",
"case_type",
"display_address",
"employment_date",
"form_type",
"period_id",
"period_str",
"ref_p_end_date",
"ref_p_start_date",
"ru_name",
"ru_ref",
"trad_as",
"user_id",
"qid":
"case_ref",
"case_type",
"display_address",
"employment_date",
"form_type",
"period_id",
"period_str",
"ref_p_end_date",
"ref_p_start_date",
"ru_name",
"ru_ref",
"trad_as",
"user_id",
"qid",
"PARTICIPANT_ID",
"FIRST_NAME",
"BLOOD_TEST_BARCODE",
"SWAB_TEST_BARCODE",
"TEST_QUESTIONS":

return true
}
return false
Expand Down Expand Up @@ -627,7 +633,12 @@ func GetRequiredMetadata(launcherSchema surveys.LauncherSchema) ([]Metadata, str
defaults := GetDefaultValues()

for i, value := range schema.Metadata {
schema.Metadata[i].Default = defaults[value.Name]

if strings.Contains(value.Name, "BARCODE") {
schema.Metadata[i].Default = "BAR" + fmt.Sprintf("%08d", rand.Int63n(1e8))
} else {
schema.Metadata[i].Default = defaults[value.Name]
}

if value.Validator == "boolean" {
schema.Metadata[i].Default = "false"
Expand Down Expand Up @@ -759,6 +770,10 @@ func GetDefaultValues() map[string]string {
defaults["postcode"] = "PE12 4GH"
defaults["display_address"] = "68 Abingdon Road, Goathill"
defaults["country"] = "E"
defaults["PARTICIPANT_ID"] = "ABC-" + fmt.Sprintf("%011d", rand.Int63n(1e11))
defaults["FIRST_NAME"] = "John"
defaults["TEST_QUESTIONS"] = "F"


return defaults
}

0 comments on commit a61d810

Please sign in to comment.