Skip to content

Commit

Permalink
add some debug for CalculateStats crash only occuring in QA
Browse files Browse the repository at this point in the history
  • Loading branch information
Roukoswarf committed Oct 1, 2023
1 parent 9e48c27 commit e41c2e3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/summary/types/cgm.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ func (s *CGMStats) CalculateSummary() {
nextStopPoint++
}

fmt.Println("total target minutes:", totalStats.TargetMinutes)
fmt.Println("current index:", currentIndex)
fmt.Println("current bucket:", s.Buckets[currentIndex])
fmt.Println("bucket target minutes:", s.Buckets[currentIndex].Data.TargetMinutes)

totalStats.TargetMinutes += s.Buckets[currentIndex].Data.TargetMinutes
totalStats.TargetRecords += s.Buckets[currentIndex].Data.TargetRecords

Expand Down
27 changes: 27 additions & 0 deletions data/summary/types/summary_cgm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,33 @@ var _ = Describe("CGM Summary", func() {
}
})

//It("Returns correct record count when given single buckets in strange places", func() {
// userCGMSummary = types.Create[types.CGMStats, *types.CGMStats](userId)
//
// // initial single bucket
// dataSetCGMDataOne := NewDataSetCGMDataAvg(deviceId, datumTime, 1, inTargetBloodGlucose)
//
// // add another single bucket forward to check off-by-one
// dataSetCGMDataTwo := NewDataSetCGMDataAvg(deviceId, datumTime.Add(1*time.Hour), 1, inTargetBloodGlucose)
//
// // 1 bucket gap
// dataSetCGMDataThree := NewDataSetCGMDataAvg(deviceId, datumTime.Add(3*time.Hour), 1, inTargetBloodGlucose)
//
// // 0 bucket gap, with overlap with previous
// dataSetCGMDataFour := NewDataSetCGMDataAvg(deviceId, datumTime.Add(3.5*60*time.Minute), 1, inTargetBloodGlucose)
//
// // same bucket as before
// dataSetCGMDataFive := NewDataSetCGMDataAvg(deviceId, datumTime.Add(4*60*time.Minute), 1, inTargetBloodGlucose)
//
// // lots of buckets ahead
// dataSetCGMDataSix := NewDataSetCGMDataAvg(deviceId, datumTime.Add(14*24*time.Hour), 1, inTargetBloodGlucose)
//
// allDataSet := make([]*glucose.Glucose, 0, len(dataSetCGMDataOne)+len(dataSetCGMDataTwo)+len(dataSetCGMDataThree)+len(dataSetCGMDataFour)+len(dataSetCGMDataFive)+len(dataSetCGMDataSix))
//
// err = userCGMSummary.Stats.Update(allDataSet)
// Expect(err).ToNot(HaveOccurred())
//})

It("Returns correctly moving offset periods", func() {
// Here we generate 5 1d datasets, and add them in a specific order:
// -59d -- target glucose
Expand Down

0 comments on commit e41c2e3

Please sign in to comment.