Skip to content

Commit

Permalink
local dev
Browse files Browse the repository at this point in the history
  • Loading branch information
joremysh committed Oct 17, 2024
1 parent 80d9d72 commit 5bf00f3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@ tmp
bin

# local
.DS_Store
.DS_Store
.idea
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions pkg/repository/influx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

0 comments on commit 5bf00f3

Please sign in to comment.