From e41c2e35836917ee72d52b3e2b7cfac62fd18bed Mon Sep 17 00:00:00 2001 From: Alexander Diana Date: Sun, 1 Oct 2023 23:15:37 +0000 Subject: [PATCH] add some debug for CalculateStats crash only occuring in QA --- data/summary/types/cgm.go | 5 +++++ data/summary/types/summary_cgm_test.go | 27 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/data/summary/types/cgm.go b/data/summary/types/cgm.go index f5dc93e21..72db167c3 100644 --- a/data/summary/types/cgm.go +++ b/data/summary/types/cgm.go @@ -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 diff --git a/data/summary/types/summary_cgm_test.go b/data/summary/types/summary_cgm_test.go index 56b284034..aaf648b72 100644 --- a/data/summary/types/summary_cgm_test.go +++ b/data/summary/types/summary_cgm_test.go @@ -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