// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: pool.sql package store import ( "context" ) const poolActiveKeyCount = `-- name: PoolActiveKeyCount :one SELECT COUNT(*) FROM pool_keys WHERE active = 1 AND revoked_at IS NULL ` func (q *Queries) PoolActiveKeyCount(ctx context.Context) (int64, error) { row := q.db.QueryRowContext(ctx, poolActiveKeyCount) var count int64 err := row.Scan(&count) return count, err } const poolContributorCount = `-- name: PoolContributorCount :one SELECT COUNT(DISTINCT user_id) FROM pool_keys WHERE active = 1 AND revoked_at IS NULL ` // Users who own at least one active pool key. func (q *Queries) PoolContributorCount(ctx context.Context) (int64, error) { row := q.db.QueryRowContext(ctx, poolContributorCount) var count int64 err := row.Scan(&count) return count, err } const poolSpentSince = `-- name: PoolSpentSince :one SELECT COALESCE(SUM(cost_micros), 0) FROM pool_key_billing_rows WHERE pioneer_created_at >= ? AND is_duplicate = 0 ` // Spend (cost_micros) from billing rows since the given unix timestamp. // Excludes duplicates. func (q *Queries) PoolSpentSince(ctx context.Context, pioneerCreatedAt int64) (interface{}, error) { row := q.db.QueryRowContext(ctx, poolSpentSince, pioneerCreatedAt) var coalesce interface{} err := row.Scan(&coalesce) return coalesce, err } const poolTokensGuzzled = `-- name: PoolTokensGuzzled :one SELECT COALESCE(SUM(token_usage), 0) AS input_tokens, 0 AS output_tokens FROM pool_key_billing_rows WHERE is_duplicate = 0 ` type PoolTokensGuzzledRow struct { InputTokens interface{} `json:"input_tokens"` OutputTokens int64 `json:"output_tokens"` } // token_usage is the total per row; split evenly across input/output so // the caller's inTok+outTok sum equals the real total. func (q *Queries) PoolTokensGuzzled(ctx context.Context) (PoolTokensGuzzledRow, error) { row := q.db.QueryRowContext(ctx, poolTokensGuzzled) var i PoolTokensGuzzledRow err := row.Scan(&i.InputTokens, &i.OutputTokens) return i, err } const poolTotalBalance = `-- name: PoolTotalBalance :one SELECT COALESCE(SUM(pioneer_credit_limit_micros), 0) AS balance_micros FROM pool_keys WHERE active = 1 AND revoked_at IS NULL ` // Pool-wide aggregates. Used by the public splash page; no auth required. // Total pioneer credit limit across all active pool keys. func (q *Queries) PoolTotalBalance(ctx context.Context) (interface{}, error) { row := q.db.QueryRowContext(ctx, poolTotalBalance) var balance_micros interface{} err := row.Scan(&balance_micros) return balance_micros, err } const poolUserCount = `-- name: PoolUserCount :one SELECT COUNT(*) FROM users ` func (q *Queries) PoolUserCount(ctx context.Context) (int64, error) { row := q.db.QueryRowContext(ctx, poolUserCount) var count int64 err := row.Scan(&count) return count, err }