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

Method IncrementUsageSummary

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

Source from the content-addressed store, hash-verified

71}
72
73func (s *Store) IncrementUsageSummary(ctx context.Context, userID, bucketDate, direction string) error {
74 inbound, outbound := 0, 0
75 if direction == "inbound" {
76 inbound = 1
77 } else {
78 outbound = 1
79 }
80 _, err := s.pool.Exec(ctx,
81 `INSERT INTO usage_summaries (user_id, bucket_date, inbound_count, outbound_count, total_count)
82 VALUES ($1, $2, $3, $4, $5)
83 ON CONFLICT (user_id, bucket_date) DO UPDATE SET
84 inbound_count = usage_summaries.inbound_count + $3,
85 outbound_count = usage_summaries.outbound_count + $4,
86 total_count = usage_summaries.total_count + $5`,
87 userID, bucketDate, inbound, outbound, inbound+outbound,
88 )
89 return err
90}
91
92// GetAccountClass returns the account class for a user. A missing user (no row)
93// resolves to ClassStandard so the metering gate fails toward metering — a

Callers 2

RecordAndCheckMethod · 0.80

Implementers 1

Storeinternal/identity/store.go

Calls 1

ExecMethod · 0.65

Tested by 1