Skip to content

Commit

Permalink
cmd/testdata.go: insert usage data on the 1th instead of 10th (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
littleskunk authored Sep 12, 2023
1 parent 1c8d6d0 commit 9939225
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func generateProjectUsage(database, email string, bucketname string, useragent s

for _, p := range projects {

dayTenOfMonth := time.Date(period.Year(), period.Month(), 10, 1, 0, 0, 0, period.Location())
firstDayOfMonth := time.Date(period.Year(), period.Month(), 1, 1, 0, 0, 0, period.Location())
lastDayOfMonth := time.Date(period.Year(), period.Month(), 1, 0, 0, 0, 0, period.Location()).AddDate(0, 1, -1)

var bucket buckets.Bucket
Expand All @@ -120,7 +120,7 @@ func generateProjectUsage(database, email string, bucketname string, useragent s
Name: bucketname,
ProjectID: p.ID,
UserAgent: []byte(useragent),
Created: dayTenOfMonth,
Created: firstDayOfMonth,
PathCipher: 0,
DefaultRedundancyScheme: storj.RedundancyScheme{},
DefaultEncryptionParameters: storj.EncryptionParameters{},
Expand All @@ -138,11 +138,11 @@ func generateProjectUsage(database, email string, bucketname string, useragent s
Object := int64(1)
SegmentCount := int64(2)

err = updateUsage(crateTally(bucket.Name, p.ID, dayTenOfMonth, Object, SegmentCount, StoredData, MetadataSize))
err = updateUsage(crateTally(bucket.Name, p.ID, firstDayOfMonth, Object, SegmentCount, StoredData, MetadataSize))
if err != nil {
return err
}
err = updateUsage(crateTally(bucket.Name, p.ID, dayTenOfMonth.Add(1*time.Minute), Object, SegmentCount, StoredData, MetadataSize))
err = updateUsage(crateTally(bucket.Name, p.ID, firstDayOfMonth.Add(1*time.Minute), Object, SegmentCount, StoredData, MetadataSize))
if err != nil {
return err
}
Expand All @@ -154,7 +154,7 @@ func generateProjectUsage(database, email string, bucketname string, useragent s
if err != nil {
return err
}
intervalStart := dayTenOfMonth
intervalStart := firstDayOfMonth
for i := 0; i < 24; i++ {
usage := 1024000000000
err = db.Orders().UpdateBucketBandwidthAllocation(ctx, p.ID, []byte(bucket.Name), pb.PieceAction_GET, int64(usage), intervalStart)
Expand All @@ -165,7 +165,7 @@ func generateProjectUsage(database, email string, bucketname string, useragent s
if err != nil {
return err
}
intervalStart = intervalStart.Add(-1 * time.Hour)
intervalStart = intervalStart.Add(1 * time.Hour)
}
err = updateStripeUser(time.Date(period.Year(), period.Month()-1, 1, 0, 0, 0, 0, time.UTC).Format("2006-01-02"))
if err != nil {
Expand Down

0 comments on commit 9939225

Please sign in to comment.