MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / GetUsageSummary

Method GetUsageSummary

internal/usage/store.go:59–71  ·  view source on GitHub ↗
(ctx context.Context, userID, bucketDate string)

Source from the content-addressed store, hash-verified

57}
58
59func (s *Store) GetUsageSummary(ctx context.Context, userID, bucketDate string) (*UsageSummary, error) {
60 sum := &UsageSummary{}
61 var bucketTime time.Time
62 err := s.pool.QueryRow(ctx,
63 `SELECT user_id, bucket_date, inbound_count, outbound_count, total_count
64 FROM usage_summaries WHERE user_id = $1 AND bucket_date = $2`, userID, bucketDate,
65 ).Scan(&sum.UserID, &bucketTime, &sum.InboundCount, &sum.OutboundCount, &sum.TotalCount)
66 if err != nil {
67 return nil, err
68 }
69 sum.BucketDate = bucketTime.Format("2006-01-02")
70 return sum, nil
71}
72
73func (s *Store) IncrementUsageSummary(ctx context.Context, userID, bucketDate, direction string) error {
74 inbound, outbound := 0, 0

Implementers 1

Storeinternal/identity/store.go

Calls 2

ScanMethod · 0.80
QueryRowMethod · 0.80