// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: client_usage.sql package db import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const upsertClientUsageDaily = `-- name: UpsertClientUsageDaily :one INSERT INTO client_usage_daily ( user_id, client_type, install_id, activity_date, workspace_id, client_version, os, first_active_at, last_active_at, runtime_probed_at, probe_result, runtime_count, provider_summary, online_count, offline_count ) VALUES ( $1, $2, $3, (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')::date, $4, $5, $6, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CASE WHEN $7::boolean THEN CURRENT_TIMESTAMP ELSE NULL END, $8, $9, $10, $11, $12 ) ON CONFLICT (user_id, client_type, install_id, activity_date) DO UPDATE SET workspace_id = COALESCE(EXCLUDED.workspace_id, client_usage_daily.workspace_id), client_version = EXCLUDED.client_version, os = EXCLUDED.os, last_active_at = EXCLUDED.last_active_at, runtime_probed_at = CASE WHEN $7::boolean THEN EXCLUDED.runtime_probed_at ELSE client_usage_daily.runtime_probed_at END, probe_result = CASE WHEN $7::boolean THEN EXCLUDED.probe_result ELSE client_usage_daily.probe_result END, runtime_count = CASE WHEN $7::boolean THEN EXCLUDED.runtime_count ELSE client_usage_daily.runtime_count END, provider_summary = CASE WHEN $7::boolean THEN EXCLUDED.provider_summary ELSE client_usage_daily.provider_summary END, online_count = CASE WHEN $7::boolean THEN EXCLUDED.online_count ELSE client_usage_daily.online_count END, offline_count = CASE WHEN $7::boolean THEN EXCLUDED.offline_count ELSE client_usage_daily.offline_count END, updated_at = CURRENT_TIMESTAMP RETURNING user_id, client_type, install_id, activity_date, workspace_id, client_version, os, first_active_at, last_active_at, runtime_probed_at, probe_result, runtime_count, provider_summary, online_count, offline_count, created_at, updated_at ` type UpsertClientUsageDailyParams struct { UserID pgtype.UUID `json:"user_id"` ClientType string `json:"client_type"` InstallID pgtype.UUID `json:"install_id"` WorkspaceID pgtype.UUID `json:"workspace_id"` ClientVersion string `json:"client_version"` Os string `json:"os"` HasRuntimeProbe bool `json:"has_runtime_probe"` ProbeResult pgtype.Text `json:"probe_result"` RuntimeCount pgtype.Int4 `json:"runtime_count"` ProviderSummary []byte `json:"provider_summary"` OnlineCount pgtype.Int4 `json:"online_count"` OfflineCount pgtype.Int4 `json:"offline_count"` } func (q *Queries) UpsertClientUsageDaily(ctx context.Context, arg UpsertClientUsageDailyParams) (ClientUsageDaily, error) { row := q.db.QueryRow(ctx, upsertClientUsageDaily, arg.UserID, arg.ClientType, arg.InstallID, arg.WorkspaceID, arg.ClientVersion, arg.Os, arg.HasRuntimeProbe, arg.ProbeResult, arg.RuntimeCount, arg.ProviderSummary, arg.OnlineCount, arg.OfflineCount, ) var i ClientUsageDaily err := row.Scan( &i.UserID, &i.ClientType, &i.InstallID, &i.ActivityDate, &i.WorkspaceID, &i.ClientVersion, &i.Os, &i.FirstActiveAt, &i.LastActiveAt, &i.RuntimeProbedAt, &i.ProbeResult, &i.RuntimeCount, &i.ProviderSummary, &i.OnlineCount, &i.OfflineCount, &i.CreatedAt, &i.UpdatedAt, ) return i, err }