Skip to content

Commit 56fd9ac

Browse files
committed
fix: fix the .last methods; add better data
1 parent ce8bb4c commit 56fd9ac

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

tests/data_generator/example_test_data_config2.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cohorts:
4040
clone_count: 2
4141
# concepts that will be created and linked to persons in this cohort via observations:
4242
concepts:
43-
- concept: concept-name
43+
- concept: concept-name-small
4444
value_type: number
4545
# this means ~1/3 of the persons in the cohort will have this concept associated to them in the observation table:
4646
ratio_of_persons: 0.34
@@ -68,7 +68,7 @@ cohorts:
6868
clone_count: 2
6969
# concepts that will be created and linked to persons in this cohort via observations:
7070
concepts:
71-
- concept: concept-name
71+
- concept: concept-name-medium
7272
value_type: number
7373
# this means ~1/3 of the persons in the cohort will have this concept associated to them in the observation table:
7474
ratio_of_persons: 0.34
@@ -96,7 +96,7 @@ cohorts:
9696
clone_count: 2
9797
# concepts that will be created and linked to persons in this cohort via observations:
9898
concepts:
99-
- concept: concept-name
99+
- concept: concept-name-large
100100
value_type: number
101101
# this means ~1/3 of the persons in the cohort will have this concept associated to them in the observation table:
102102
ratio_of_persons: 0.34

tests/testutils.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func EmptyTable(dataSource *utils.DbAndSchema, tableName string) {
109109
func GetLastCohortId() int {
110110
dataSource := db.GetAtlasDB()
111111
var lastCohortDefinition models.CohortDefinition
112-
dataSource.Db.Last(&lastCohortDefinition)
112+
dataSource.Db.Order("id DESC").First(&lastCohortDefinition)
113113
return lastCohortDefinition.Id
114114
}
115115

@@ -124,21 +124,23 @@ func GetNextCohortId() int {
124124
func GetLastConceptId(sourceId int) int64 {
125125
dataSource := GetOmopDataSourceForSourceId(sourceId)
126126
var lastConcept models.Concept
127-
dataSource.Db.Last(&lastConcept)
127+
dataSource.Db.Order("concept_id DESC").First(&lastConcept)
128+
log.Printf("Last concept id found %d",
129+
lastConcept.ConceptId)
128130
return lastConcept.ConceptId
129131
}
130132

131133
func GetLastObservationId(sourceId int) int64 {
132134
dataSource := GetOmopDataSourceForSourceId(sourceId)
133135
var lastObservation models.Observation
134-
dataSource.Db.Last(&lastObservation)
136+
dataSource.Db.Order("observation_id DESC").First(&lastObservation)
135137
return lastObservation.ObservationId
136138
}
137139

138140
func GetLastPersonId(sourceId int) int64 {
139141
dataSource := GetOmopDataSourceForSourceId(sourceId)
140142
var lastPerson models.Person
141-
dataSource.Db.Last(&lastPerson)
143+
dataSource.Db.Order("person_id DESC").First(&lastPerson)
142144
return lastPerson.PersonId
143145
}
144146

0 commit comments

Comments
 (0)