@@ -102,7 +102,7 @@ func handleCopy(cfg *config.Config, dest *storage.API) content.HandlerFunc {
102
102
g .SetLimit (concurrency )
103
103
104
104
for date := start ; ! date .After (end ); date = date .AddDate (0 , 0 , 1 ) {
105
- it := sourceBucket .Objects (ctx , date .Format (time .DateOnly ))
105
+ it := sourceBucket .Objects (ctx , date .Format (telemetry .DateOnly ))
106
106
for {
107
107
fileName , err := it .Next ()
108
108
if errors .Is (err , storage .ErrObjectIteratorDone ) {
@@ -138,13 +138,13 @@ func handleTasks(cfg *config.Config) content.HandlerFunc {
138
138
139
139
// Copy the past 20 days uploaded reports from prod to dev gcs bucket.
140
140
if cfg .Env != "prod" {
141
- url := cfg .WorkerURL + "/copy/?start=" + now .AddDate (0 , 0 , - 1 * 20 ).Format (time .DateOnly ) + "&end=" + now .Format (time .DateOnly )
141
+ url := cfg .WorkerURL + "/copy/?start=" + now .AddDate (0 , 0 , - 1 * 20 ).Format (telemetry .DateOnly ) + "&end=" + now .Format (telemetry .DateOnly )
142
142
if _ , err := createHTTPTask (cfg , url ); err != nil {
143
143
return err
144
144
}
145
145
}
146
146
for i := 7 ; i > 0 ; i -- {
147
- date := now .AddDate (0 , 0 , - 1 * i ).Format (time .DateOnly )
147
+ date := now .AddDate (0 , 0 , - 1 * i ).Format (telemetry .DateOnly )
148
148
url := cfg .WorkerURL + "/merge/?date=" + date
149
149
if _ , err := createHTTPTask (cfg , url ); err != nil {
150
150
return err
@@ -154,7 +154,7 @@ func handleTasks(cfg *config.Config) content.HandlerFunc {
154
154
// coded one day delay.
155
155
for i := 8 ; i > 1 ; i -- {
156
156
// Daily chart: generate chart using one day's data.
157
- date := now .AddDate (0 , 0 , - 1 * i ).Format (time .DateOnly )
157
+ date := now .AddDate (0 , 0 , - 1 * i ).Format (telemetry .DateOnly )
158
158
url := cfg .WorkerURL + "/chart/?date=" + date
159
159
if _ , err := createHTTPTask (cfg , url ); err != nil {
160
160
return err
@@ -163,7 +163,7 @@ func handleTasks(cfg *config.Config) content.HandlerFunc {
163
163
// Weekly chart: generate chart using past 7 days' data.
164
164
end := now .AddDate (0 , 0 , - 1 * i )
165
165
start := end .AddDate (0 , 0 , - 6 )
166
- url = cfg .WorkerURL + "/chart/?start=" + start .Format (time .DateOnly ) + "&end=" + end .Format (time .DateOnly )
166
+ url = cfg .WorkerURL + "/chart/?start=" + start .Format (telemetry .DateOnly ) + "&end=" + end .Format (telemetry .DateOnly )
167
167
if _ , err := createHTTPTask (cfg , url ); err != nil {
168
168
return err
169
169
}
@@ -213,7 +213,7 @@ func handleMerge(s *storage.API) content.HandlerFunc {
213
213
return func (w http.ResponseWriter , r * http.Request ) error {
214
214
ctx := r .Context ()
215
215
date := r .URL .Query ().Get ("date" )
216
- if _ , err := time .Parse (time .DateOnly , date ); err != nil {
216
+ if _ , err := time .Parse (telemetry .DateOnly , date ); err != nil {
217
217
return content .Error (err , http .StatusBadRequest )
218
218
}
219
219
it := s .Upload .Objects (ctx , date )
@@ -259,10 +259,10 @@ func handleMerge(s *storage.API) content.HandlerFunc {
259
259
260
260
func fileName (start , end time.Time ) string {
261
261
if start .Equal (end ) {
262
- return end .Format (time .DateOnly ) + ".json"
262
+ return end .Format (telemetry .DateOnly ) + ".json"
263
263
}
264
264
265
- return start .Format (time .DateOnly ) + "_" + end .Format (time .DateOnly ) + ".json"
265
+ return start .Format (telemetry .DateOnly ) + "_" + end .Format (telemetry .DateOnly ) + ".json"
266
266
}
267
267
268
268
// parseDateRange returns the start and end date from the given url.
@@ -271,7 +271,7 @@ func parseDateRange(url *url.URL) (start, end time.Time, _ error) {
271
271
if url .Query ().Get ("start" ) != "" || url .Query ().Get ("end" ) != "" {
272
272
return time.Time {}, time.Time {}, content .Error (fmt .Errorf ("start or end key should be empty when date key is being used" ), http .StatusBadRequest )
273
273
}
274
- date , err := time .Parse (time .DateOnly , dateString )
274
+ date , err := time .Parse (telemetry .DateOnly , dateString )
275
275
if err != nil {
276
276
return time.Time {}, time.Time {}, content .Error (err , http .StatusBadRequest )
277
277
}
@@ -280,12 +280,12 @@ func parseDateRange(url *url.URL) (start, end time.Time, _ error) {
280
280
281
281
var err error
282
282
startString := url .Query ().Get ("start" )
283
- start , err = time .Parse (time .DateOnly , startString )
283
+ start , err = time .Parse (telemetry .DateOnly , startString )
284
284
if err != nil {
285
285
return time.Time {}, time.Time {}, content .Error (err , http .StatusBadRequest )
286
286
}
287
287
endString := url .Query ().Get ("end" )
288
- end , err = time .Parse (time .DateOnly , endString )
288
+ end , err = time .Parse (telemetry .DateOnly , endString )
289
289
if err != nil {
290
290
return time.Time {}, time.Time {}, content .Error (err , http .StatusBadRequest )
291
291
}
@@ -330,7 +330,7 @@ func handleChart(cfg *tconfig.Config, s *storage.API) content.HandlerFunc {
330
330
var reports []telemetry.Report
331
331
var xs []float64
332
332
for date := start ; ! date .After (end ); date = date .AddDate (0 , 0 , 1 ) {
333
- dailyReports , err := readMergedReports (ctx , date .Format (time .DateOnly )+ ".json" , s )
333
+ dailyReports , err := readMergedReports (ctx , date .Format (telemetry .DateOnly )+ ".json" , s )
334
334
if err != nil {
335
335
return err
336
336
}
@@ -341,7 +341,7 @@ func handleChart(cfg *tconfig.Config, s *storage.API) content.HandlerFunc {
341
341
}
342
342
343
343
data := nest (reports )
344
- charts := charts (cfg , start .Format (time .DateOnly ), end .Format (time .DateOnly ), data , xs )
344
+ charts := charts (cfg , start .Format (telemetry .DateOnly ), end .Format (telemetry .DateOnly ), data , xs )
345
345
346
346
obj := fileName (start , end )
347
347
out , err := s .Chart .Object (obj ).NewWriter (ctx )
@@ -357,7 +357,7 @@ func handleChart(cfg *tconfig.Config, s *storage.API) content.HandlerFunc {
357
357
return err
358
358
}
359
359
360
- msg := fmt .Sprintf ("processed %d reports from date %s to %s into %s" , len (reports ), start .Format (time .DateOnly ), end .Format (time .DateOnly ), s .Chart .URI ()+ "/" + obj )
360
+ msg := fmt .Sprintf ("processed %d reports from date %s to %s into %s" , len (reports ), start .Format (telemetry .DateOnly ), end .Format (telemetry .DateOnly ), s .Chart .URI ()+ "/" + obj )
361
361
return content .Text (w , msg , http .StatusOK )
362
362
}
363
363
}
0 commit comments