From 5bf00f365714ce14e21c0c05030db3e97eb0ec20 Mon Sep 17 00:00:00 2001 From: Jeremy Shih Date: Thu, 17 Oct 2024 11:46:39 +0800 Subject: [PATCH] local dev --- .gitignore | 3 ++- go.mod | 2 +- go.sum | 6 ++---- pkg/repository/influx.go | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index c4aae29..86c93ff 100644 --- a/.gitignore +++ b/.gitignore @@ -110,4 +110,5 @@ tmp bin # local -.DS_Store \ No newline at end of file +.DS_Store +.idea diff --git a/go.mod b/go.mod index e906ed9..62bc0c6 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 github.com/iancoleman/strcase v0.2.0 github.com/influxdata/influxdb-client-go/v2 v2.12.3 - github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240726044326-e2dcf1c317f4 // TODO reference commit once merged + github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241017053954-504e93a4d715 // TODO reference commit once merged github.com/instill-ai/usage-client v0.2.4-alpha.0.20240123081026-6c78d9a5197a github.com/instill-ai/x v0.4.0-alpha github.com/knadh/koanf v1.5.0 diff --git a/go.sum b/go.sum index d2375f8..b7d8c36 100644 --- a/go.sum +++ b/go.sum @@ -1090,10 +1090,8 @@ github.com/influxdata/influxdb-client-go/v2 v2.12.3 h1:28nRlNMRIV4QbtIUvxhWqaxn0 github.com/influxdata/influxdb-client-go/v2 v2.12.3/go.mod h1:IrrLUbCjjfkmRuaCiGQg4m2GbkaeJDcuWoxiWdQEbA0= github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7wlPfJLvMCdtV4zPulc4uCPrlywQOmbFOhgQNU= github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= -github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240725140016-18f3ff64c952 h1:gtc9vYwc5sEWIs5H1bdu0vx5IgZb0CKcvBa0VWtU8VE= -github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240725140016-18f3ff64c952/go.mod h1:2blmpUwiTwxIDnrjIqT6FhR5ewshZZF554wzjXFvKpQ= -github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240726044326-e2dcf1c317f4 h1:LTnrCSgLcgYLQR43NGrAswAQ+XroDAbLEvCMTK//AxU= -github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240726044326-e2dcf1c317f4/go.mod h1:2blmpUwiTwxIDnrjIqT6FhR5ewshZZF554wzjXFvKpQ= +github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241017053954-504e93a4d715 h1:SyFyHQhwNy0TMl9v5mocWuLdJ2NrW+JMXbcdUJE5reA= +github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241017053954-504e93a4d715/go.mod h1:rf0UY7VpEgpaLudYEcjx5rnbuwlBaaLyD4FQmWLtgAY= github.com/instill-ai/usage-client v0.2.4-alpha.0.20240123081026-6c78d9a5197a h1:gmy8BcCFDZQan40c/D3f62DwTYtlCwi0VrSax+pKffw= github.com/instill-ai/usage-client v0.2.4-alpha.0.20240123081026-6c78d9a5197a/go.mod h1:EpX3Yr661uWULtZf5UnJHfr5rw2PDyX8ku4Kx0UtYFw= github.com/instill-ai/x v0.4.0-alpha h1:zQV2VLbSHjMv6gyBN/2mwwrvWk0/mJM6ZKS12AzjfQg= diff --git a/pkg/repository/influx.go b/pkg/repository/influx.go index c922bbc..a77281d 100644 --- a/pkg/repository/influx.go +++ b/pkg/repository/influx.go @@ -136,7 +136,7 @@ func (i *influxDB) ListPipelineTriggerChartRecords( p.Stop.Format(time.RFC3339Nano), p.NamespaceUID.String(), p.AggregationWindow, - aggregationWindowOffset(p.Start).String(), + AggregationWindowOffset(p.Start).String(), ) result, err := i.QueryAPI().Query(ctx, query) if err != nil { @@ -257,12 +257,12 @@ func (i *influxDB) GetPipelineTriggerCount( }, nil } -// aggregationWindowOffset computes the offset to apply to InfluxDB's +// AggregationWindowOffset computes the offset to apply to InfluxDB's // aggregateWindow function when aggregating by day. This function computes // windows independently, starting from the Unix epoch, rather than from the // provided time range start. This function computes the offset to shift the // windows correctly. -func aggregationWindowOffset(t time.Time) time.Duration { +func AggregationWindowOffset(t time.Time) time.Duration { startOfDay := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.UTC) return t.Sub(startOfDay) }