Skip to content

Commit ddb51d7

Browse files
committed
truncate file date to hour if scheduling is
1 parent 52ad3a3 commit ddb51d7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

business/tsextractor/tsextractor.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,15 @@ func (a *TsExtractor) ExportTSToS3(
128128
writer.Close()
129129
defer writer.Delete()
130130

131-
destinationKey := fmt.Sprintf("%s/%s.csv", from.Format("2006-01-02"), from.Format("2006-01-02-15-04"))
131+
var formattedFrom string
132+
if resolution == 3600 {
133+
formattedFrom = from.Format("2006-01-02-15-00")
134+
} else if resolution > 3600 {
135+
formattedFrom = from.Format("2006-01-02-00-00")
136+
} else {
137+
formattedFrom = from.Format("2006-01-02-15-04")
138+
}
139+
destinationKey := fmt.Sprintf("%s/%s.csv", from.Format("2006-01-02"), formattedFrom)
132140
a.logger.Infof("Uploading file %s to bucket %s\n", destinationKey, s3cl.DestinationBucket())
133141
if err := s3cl.WriteFile(ctx, destinationKey, writer.GetFilePath()); err != nil {
134142
return err

0 commit comments

Comments
 (0)