MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / trackWeeklyUsage

Method trackWeeklyUsage

internal/services/usage.go:175–182  ·  view source on GitHub ↗
(ctx context.Context, userID bson.ObjectID, projectID string, cost float64, success bool, now time.Time)

Source from the content-addressed store, hash-verified

173}
174
175func (s *UsageService) trackWeeklyUsage(ctx context.Context, userID bson.ObjectID, projectID string, cost float64, success bool, now time.Time) error {
176 filter := bson.M{
177 "user_id": userID,
178 "project_id": projectID,
179 "week_bucket": bson.NewDateTimeFromTime(models.TruncateToWeek(now)),
180 }
181 return s.upsertUsage(ctx, s.weeklyCollection, filter, cost, success, now)
182}
183
184func (s *UsageService) trackLifetimeUsage(ctx context.Context, userID bson.ObjectID, projectID string, cost float64, success bool, now time.Time) error {
185 filter := bson.M{

Callers 1

TrackUsageMethod · 0.95

Calls 2

upsertUsageMethod · 0.95
TruncateToWeekFunction · 0.92

Tested by

no test coverage detected