diff --git a/webapp/backend/pkg/database/scrutiny_repository.go b/webapp/backend/pkg/database/scrutiny_repository.go index da95914c..f2fa3faf 100644 --- a/webapp/backend/pkg/database/scrutiny_repository.go +++ b/webapp/backend/pkg/database/scrutiny_repository.go @@ -29,6 +29,7 @@ const ( // 60seconds * 60minutes * 24hours * 7 days * (52 + 52 + 4)weeks RETENTION_PERIOD_25_MONTHS_IN_SECONDS = 65_318_400 + DURATION_KEY_DAY = "day" DURATION_KEY_WEEK = "week" DURATION_KEY_MONTH = "month" DURATION_KEY_YEAR = "year" @@ -445,6 +446,7 @@ func (sr *scrutinyRepository) GetSummary(ctx context.Context) (map[string]*model func (sr *scrutinyRepository) lookupBucketName(durationKey string) string { switch durationKey { + case DURATION_KEY_DAY: case DURATION_KEY_WEEK: //data stored in the last week return sr.appConfig.GetString("web.influxdb.bucket") @@ -462,8 +464,10 @@ func (sr *scrutinyRepository) lookupBucketName(durationKey string) string { } func (sr *scrutinyRepository) lookupDuration(durationKey string) []string { - switch durationKey { + case DURATION_KEY_DAY: + //data stored in the last day + return []string{"-1d", "now()"} case DURATION_KEY_WEEK: //data stored in the last week return []string{"-1w", "now()"} @@ -480,8 +484,22 @@ func (sr *scrutinyRepository) lookupDuration(durationKey string) []string { return []string{"-1w", "now()"} } +func (sr *scrutinyRepository) lookupResolution(durationKey string) string { + switch durationKey { + case DURATION_KEY_DAY: + // Return data with higher resolution for daily summaries + return "10m" + default: + // Return data with 1h resolution for other summaries + return "1h" + } +} + func (sr *scrutinyRepository) lookupNestedDurationKeys(durationKey string) []string { switch durationKey { + case DURATION_KEY_DAY: + //all data is stored in a single bucket, but we want a finer resolution + return []string{DURATION_KEY_DAY} case DURATION_KEY_WEEK: //all data is stored in a single bucket return []string{DURATION_KEY_WEEK} diff --git a/webapp/backend/pkg/database/scrutiny_repository_temperature.go b/webapp/backend/pkg/database/scrutiny_repository_temperature.go index 9edec87e..5ccbc8e7 100644 --- a/webapp/backend/pkg/database/scrutiny_repository_temperature.go +++ b/webapp/backend/pkg/database/scrutiny_repository_temperature.go @@ -138,13 +138,14 @@ func (sr *scrutinyRepository) aggregateTempQuery(durationKey string) string { for _, nestedDurationKey := range nestedDurationKeys { bucketName := sr.lookupBucketName(nestedDurationKey) durationRange := sr.lookupDuration(nestedDurationKey) + durationResolution := sr.lookupResolution(nestedDurationKey) subQueryNames = append(subQueryNames, fmt.Sprintf(`%sData`, nestedDurationKey)) partialQueryStr = append(partialQueryStr, []string{ fmt.Sprintf(`%sData = from(bucket: "%s")`, nestedDurationKey, bucketName), fmt.Sprintf(`|> range(start: %s, stop: %s)`, durationRange[0], durationRange[1]), `|> filter(fn: (r) => r["_measurement"] == "temp" )`, - `|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)`, + fmt.Sprintf(`|> aggregateWindow(every: %s, fn: mean, createEmpty: false)`, durationResolution), `|> group(columns: ["device_wwn"])`, `|> toInt()`, "", @@ -167,5 +168,6 @@ func (sr *scrutinyRepository) aggregateTempQuery(durationKey string) string { }...) } + return strings.Join(partialQueryStr, "\n") } diff --git a/webapp/frontend/src/app/modules/dashboard/dashboard.component.html b/webapp/frontend/src/app/modules/dashboard/dashboard.component.html index 872387fc..51b6d547 100644 --- a/webapp/frontend/src/app/modules/dashboard/dashboard.component.html +++ b/webapp/frontend/src/app/modules/dashboard/dashboard.component.html @@ -96,6 +96,7 @@

{{ hostId.key }}

+ diff --git a/webapp/frontend/src/app/modules/dashboard/dashboard.component.ts b/webapp/frontend/src/app/modules/dashboard/dashboard.component.ts index bdd166ce..febf633a 100644 --- a/webapp/frontend/src/app/modules/dashboard/dashboard.component.ts +++ b/webapp/frontend/src/app/modules/dashboard/dashboard.component.ts @@ -269,11 +269,11 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy } /* - + DURATION_KEY_DAY = "day" DURATION_KEY_WEEK = "week" - DURATION_KEY_MONTH = "month" - DURATION_KEY_YEAR = "year" - DURATION_KEY_FOREVER = "forever" + DURATION_KEY_MONTH = "month" + DURATION_KEY_YEAR = "year" + DURATION_KEY_FOREVER = "forever" */ changeSummaryTempDuration(durationKey: string): void {