// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: AnalyticsCache.sql package store import ( "context" "encoding/json" "time" ) const deleteAnalyticsCache = `-- name: DeleteAnalyticsCache :exec DELETE FROM analytics_cache WHERE user_id = $1 AND platform = $2 AND tool_name = $3 AND time_range_hash = $4 ` type DeleteAnalyticsCacheParams struct { UserID string Platform string ToolName string TimeRangeHash string } func (q *Queries) DeleteAnalyticsCache(ctx context.Context, arg DeleteAnalyticsCacheParams) error { _, err := q.db.ExecContext(ctx, deleteAnalyticsCache, arg.UserID, arg.Platform, arg.ToolName, arg.TimeRangeHash, ) return err } const getAnalyticsCache = `-- name: GetAnalyticsCache :one SELECT result FROM analytics_cache WHERE user_id = $1 AND platform = $2 AND tool_name = $3 AND time_range_hash = $4 AND expires_at > now() ` type GetAnalyticsCacheParams struct { UserID string Platform string ToolName string TimeRangeHash string } func (q *Queries) GetAnalyticsCache(ctx context.Context, arg GetAnalyticsCacheParams) (json.RawMessage, error) { row := q.db.QueryRowContext(ctx, getAnalyticsCache, arg.UserID, arg.Platform, arg.ToolName, arg.TimeRangeHash, ) var result json.RawMessage err := row.Scan(&result) return result, err } const pruneAnalyticsCache = `-- name: PruneAnalyticsCache :exec DELETE FROM analytics_cache WHERE expires_at <= now() ` func (q *Queries) PruneAnalyticsCache(ctx context.Context) error { _, err := q.db.ExecContext(ctx, pruneAnalyticsCache) return err } const upsertAnalyticsCache = `-- name: UpsertAnalyticsCache :exec INSERT INTO analytics_cache (user_id, platform, tool_name, time_range_hash, result, expires_at) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (user_id, platform, tool_name, time_range_hash) DO UPDATE SET result = EXCLUDED.result, expires_at = EXCLUDED.expires_at, computed_at = now() ` type UpsertAnalyticsCacheParams struct { UserID string Platform string ToolName string TimeRangeHash string Result json.RawMessage ExpiresAt time.Time } func (q *Queries) UpsertAnalyticsCache(ctx context.Context, arg UpsertAnalyticsCacheParams) error { _, err := q.db.ExecContext(ctx, upsertAnalyticsCache, arg.UserID, arg.Platform, arg.ToolName, arg.TimeRangeHash, arg.Result, arg.ExpiresAt, ) return err }