mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore(db): remove 23 unused database methods (#22999)
Removes 22 database query methods with no callers outside generated code and the dbauthz wrapper layer (~1,600 lines). **Security keys (6)** — superseded by `cryptokeys` package: `GetAppSecurityKey`, `UpsertAppSecurityKey`, `GetOAuthSigningKey`, `UpsertOAuthSigningKey`, `GetCoordinatorResumeTokenSigningKey`, `UpsertCoordinatorResumeTokenSigningKey` **Superseded queries (4):** - `GetProvisionerJobsByIDs` → `GetProvisionerJobsByIDsWithQueuePosition` - `GetDeploymentDAUs` / `GetTemplateDAUs` → `GetTemplateInsightsByInterval` - `GetWorkspaceBuildParametersByBuildIDs` + its `GetAuthorized...` variant → unused **OAuth2 (2):** `GetOAuth2ProviderAppByRegistrationToken`, `UpdateOAuth2ProviderAppSecretByID` **Chat (4)** — pre-wired with no callers: `GetChatModelConfigByProviderAndModel`, `DeleteChatMessagesByChatID`, `ListChatsByRootID`, `ListChildChatsByParentID` **Other (6):** `DeleteGitSSHKey`, `UpdateUserLinkedID`, `GetFileIDByTemplateVersionID`, `GetTemplateVersionHasAITask`, `InsertUserGroupsByName`, `RemoveUserFromAllGroups`
This commit is contained in:
@@ -2360,50 +2360,6 @@ func (q *sqlQuerier) GetChatModelConfigByID(ctx context.Context, id uuid.UUID) (
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getChatModelConfigByProviderAndModel = `-- name: GetChatModelConfigByProviderAndModel :one
|
||||
SELECT
|
||||
id, provider, model, display_name, created_by, updated_by, enabled, is_default, deleted, deleted_at, created_at, updated_at, context_limit, compression_threshold, options
|
||||
FROM
|
||||
chat_model_configs
|
||||
WHERE
|
||||
provider = $1::text
|
||||
AND model = $2::text
|
||||
AND deleted = FALSE
|
||||
ORDER BY
|
||||
updated_at DESC,
|
||||
created_at DESC,
|
||||
id DESC
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetChatModelConfigByProviderAndModelParams struct {
|
||||
Provider string `db:"provider" json:"provider"`
|
||||
Model string `db:"model" json:"model"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) GetChatModelConfigByProviderAndModel(ctx context.Context, arg GetChatModelConfigByProviderAndModelParams) (ChatModelConfig, error) {
|
||||
row := q.db.QueryRowContext(ctx, getChatModelConfigByProviderAndModel, arg.Provider, arg.Model)
|
||||
var i ChatModelConfig
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Provider,
|
||||
&i.Model,
|
||||
&i.DisplayName,
|
||||
&i.CreatedBy,
|
||||
&i.UpdatedBy,
|
||||
&i.Enabled,
|
||||
&i.IsDefault,
|
||||
&i.Deleted,
|
||||
&i.DeletedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ContextLimit,
|
||||
&i.CompressionThreshold,
|
||||
&i.Options,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getChatModelConfigs = `-- name: GetChatModelConfigs :many
|
||||
SELECT
|
||||
id, provider, model, display_name, created_by, updated_by, enabled, is_default, deleted, deleted_at, created_at, updated_at, context_limit, compression_threshold, options
|
||||
@@ -3200,18 +3156,6 @@ func (q *sqlQuerier) DeleteChatMessagesAfterID(ctx context.Context, arg DeleteCh
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteChatMessagesByChatID = `-- name: DeleteChatMessagesByChatID :exec
|
||||
DELETE FROM
|
||||
chat_messages
|
||||
WHERE
|
||||
chat_id = $1::uuid
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) DeleteChatMessagesByChatID(ctx context.Context, chatID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteChatMessagesByChatID, chatID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteChatQueuedMessage = `-- name: DeleteChatQueuedMessage :exec
|
||||
DELETE FROM chat_queued_messages WHERE id = $1 AND chat_id = $2
|
||||
`
|
||||
@@ -3957,106 +3901,6 @@ func (q *sqlQuerier) InsertChatQueuedMessage(ctx context.Context, arg InsertChat
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listChatsByRootID = `-- name: ListChatsByRootID :many
|
||||
SELECT
|
||||
id, owner_id, workspace_id, title, status, worker_id, started_at, heartbeat_at, created_at, updated_at, parent_chat_id, root_chat_id, last_model_config_id, archived, last_error
|
||||
FROM
|
||||
chats
|
||||
WHERE
|
||||
root_chat_id = $1::uuid
|
||||
ORDER BY
|
||||
created_at ASC
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) ListChatsByRootID(ctx context.Context, rootChatID uuid.UUID) ([]Chat, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listChatsByRootID, rootChatID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Chat
|
||||
for rows.Next() {
|
||||
var i Chat
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.OwnerID,
|
||||
&i.WorkspaceID,
|
||||
&i.Title,
|
||||
&i.Status,
|
||||
&i.WorkerID,
|
||||
&i.StartedAt,
|
||||
&i.HeartbeatAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ParentChatID,
|
||||
&i.RootChatID,
|
||||
&i.LastModelConfigID,
|
||||
&i.Archived,
|
||||
&i.LastError,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listChildChatsByParentID = `-- name: ListChildChatsByParentID :many
|
||||
SELECT
|
||||
id, owner_id, workspace_id, title, status, worker_id, started_at, heartbeat_at, created_at, updated_at, parent_chat_id, root_chat_id, last_model_config_id, archived, last_error
|
||||
FROM
|
||||
chats
|
||||
WHERE
|
||||
parent_chat_id = $1::uuid
|
||||
ORDER BY
|
||||
created_at ASC
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) ListChildChatsByParentID(ctx context.Context, parentChatID uuid.UUID) ([]Chat, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listChildChatsByParentID, parentChatID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Chat
|
||||
for rows.Next() {
|
||||
var i Chat
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.OwnerID,
|
||||
&i.WorkspaceID,
|
||||
&i.Title,
|
||||
&i.Status,
|
||||
&i.WorkerID,
|
||||
&i.StartedAt,
|
||||
&i.HeartbeatAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ParentChatID,
|
||||
&i.RootChatID,
|
||||
&i.LastModelConfigID,
|
||||
&i.Archived,
|
||||
&i.LastError,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const popNextQueuedMessage = `-- name: PopNextQueuedMessage :one
|
||||
DELETE FROM chat_queued_messages
|
||||
WHERE id = (
|
||||
@@ -5581,30 +5425,6 @@ func (q *sqlQuerier) GetFileByID(ctx context.Context, id uuid.UUID) (File, error
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getFileIDByTemplateVersionID = `-- name: GetFileIDByTemplateVersionID :one
|
||||
SELECT
|
||||
files.id
|
||||
FROM
|
||||
files
|
||||
JOIN
|
||||
provisioner_jobs ON
|
||||
provisioner_jobs.storage_method = 'file'
|
||||
AND provisioner_jobs.file_id = files.id
|
||||
JOIN
|
||||
template_versions ON template_versions.job_id = provisioner_jobs.id
|
||||
WHERE
|
||||
template_versions.id = $1
|
||||
LIMIT
|
||||
1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetFileIDByTemplateVersionID(ctx context.Context, templateVersionID uuid.UUID) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getFileIDByTemplateVersionID, templateVersionID)
|
||||
var id uuid.UUID
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
||||
const getFileTemplates = `-- name: GetFileTemplates :many
|
||||
SELECT
|
||||
files.id AS file_id,
|
||||
@@ -5711,18 +5531,6 @@ func (q *sqlQuerier) InsertFile(ctx context.Context, arg InsertFileParams) (File
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteGitSSHKey = `-- name: DeleteGitSSHKey :exec
|
||||
DELETE FROM
|
||||
gitsshkeys
|
||||
WHERE
|
||||
user_id = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) DeleteGitSSHKey(ctx context.Context, userID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteGitSSHKey, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getGitSSHKey = `-- name: GetGitSSHKey :one
|
||||
SELECT
|
||||
user_id, created_at, updated_at, private_key, public_key
|
||||
@@ -6047,49 +5855,6 @@ func (q *sqlQuerier) InsertUserGroupsByID(ctx context.Context, arg InsertUserGro
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const insertUserGroupsByName = `-- name: InsertUserGroupsByName :exec
|
||||
WITH groups AS (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
groups
|
||||
WHERE
|
||||
groups.organization_id = $2 AND
|
||||
groups.name = ANY($3 :: text [])
|
||||
)
|
||||
INSERT INTO
|
||||
group_members (user_id, group_id)
|
||||
SELECT
|
||||
$1,
|
||||
groups.id
|
||||
FROM
|
||||
groups
|
||||
`
|
||||
|
||||
type InsertUserGroupsByNameParams struct {
|
||||
UserID uuid.UUID `db:"user_id" json:"user_id"`
|
||||
OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"`
|
||||
GroupNames []string `db:"group_names" json:"group_names"`
|
||||
}
|
||||
|
||||
// InsertUserGroupsByName adds a user to all provided groups, if they exist.
|
||||
func (q *sqlQuerier) InsertUserGroupsByName(ctx context.Context, arg InsertUserGroupsByNameParams) error {
|
||||
_, err := q.db.ExecContext(ctx, insertUserGroupsByName, arg.UserID, arg.OrganizationID, pq.Array(arg.GroupNames))
|
||||
return err
|
||||
}
|
||||
|
||||
const removeUserFromAllGroups = `-- name: RemoveUserFromAllGroups :exec
|
||||
DELETE FROM
|
||||
group_members
|
||||
WHERE
|
||||
user_id = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) RemoveUserFromAllGroups(ctx context.Context, userID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, removeUserFromAllGroups, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
const removeUserFromGroups = `-- name: RemoveUserFromGroups :many
|
||||
DELETE FROM
|
||||
group_members
|
||||
@@ -9074,44 +8839,6 @@ func (q *sqlQuerier) GetOAuth2ProviderAppByID(ctx context.Context, id uuid.UUID)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getOAuth2ProviderAppByRegistrationToken = `-- name: GetOAuth2ProviderAppByRegistrationToken :one
|
||||
SELECT id, created_at, updated_at, name, icon, callback_url, redirect_uris, client_type, dynamically_registered, client_id_issued_at, client_secret_expires_at, grant_types, response_types, token_endpoint_auth_method, scope, contacts, client_uri, logo_uri, tos_uri, policy_uri, jwks_uri, jwks, software_id, software_version, registration_access_token, registration_client_uri FROM oauth2_provider_apps WHERE registration_access_token = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetOAuth2ProviderAppByRegistrationToken(ctx context.Context, registrationAccessToken []byte) (OAuth2ProviderApp, error) {
|
||||
row := q.db.QueryRowContext(ctx, getOAuth2ProviderAppByRegistrationToken, registrationAccessToken)
|
||||
var i OAuth2ProviderApp
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Name,
|
||||
&i.Icon,
|
||||
&i.CallbackURL,
|
||||
pq.Array(&i.RedirectUris),
|
||||
&i.ClientType,
|
||||
&i.DynamicallyRegistered,
|
||||
&i.ClientIDIssuedAt,
|
||||
&i.ClientSecretExpiresAt,
|
||||
pq.Array(&i.GrantTypes),
|
||||
pq.Array(&i.ResponseTypes),
|
||||
&i.TokenEndpointAuthMethod,
|
||||
&i.Scope,
|
||||
pq.Array(&i.Contacts),
|
||||
&i.ClientUri,
|
||||
&i.LogoUri,
|
||||
&i.TosUri,
|
||||
&i.PolicyUri,
|
||||
&i.JwksUri,
|
||||
&i.Jwks,
|
||||
&i.SoftwareID,
|
||||
&i.SoftwareVersion,
|
||||
&i.RegistrationAccessToken,
|
||||
&i.RegistrationClientUri,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getOAuth2ProviderAppCodeByID = `-- name: GetOAuth2ProviderAppCodeByID :one
|
||||
SELECT id, created_at, expires_at, secret_prefix, hashed_secret, user_id, app_id, resource_uri, code_challenge, code_challenge_method, state_hash, redirect_uri FROM oauth2_provider_app_codes WHERE id = $1
|
||||
`
|
||||
@@ -9951,32 +9678,6 @@ func (q *sqlQuerier) UpdateOAuth2ProviderAppByID(ctx context.Context, arg Update
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateOAuth2ProviderAppSecretByID = `-- name: UpdateOAuth2ProviderAppSecretByID :one
|
||||
UPDATE oauth2_provider_app_secrets SET
|
||||
last_used_at = $2
|
||||
WHERE id = $1 RETURNING id, created_at, last_used_at, hashed_secret, display_secret, app_id, secret_prefix
|
||||
`
|
||||
|
||||
type UpdateOAuth2ProviderAppSecretByIDParams struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
LastUsedAt sql.NullTime `db:"last_used_at" json:"last_used_at"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) UpdateOAuth2ProviderAppSecretByID(ctx context.Context, arg UpdateOAuth2ProviderAppSecretByIDParams) (OAuth2ProviderAppSecret, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateOAuth2ProviderAppSecretByID, arg.ID, arg.LastUsedAt)
|
||||
var i OAuth2ProviderAppSecret
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.LastUsedAt,
|
||||
&i.HashedSecret,
|
||||
&i.DisplaySecret,
|
||||
&i.AppID,
|
||||
&i.SecretPrefix,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteOrganizationMember = `-- name: DeleteOrganizationMember :exec
|
||||
DELETE
|
||||
FROM
|
||||
@@ -12845,60 +12546,6 @@ func (q *sqlQuerier) GetProvisionerJobTimingsByJobID(ctx context.Context, jobID
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProvisionerJobsByIDs = `-- name: GetProvisionerJobsByIDs :many
|
||||
SELECT
|
||||
id, created_at, updated_at, started_at, canceled_at, completed_at, error, organization_id, initiator_id, provisioner, storage_method, type, input, worker_id, file_id, tags, error_code, trace_metadata, job_status, logs_length, logs_overflowed
|
||||
FROM
|
||||
provisioner_jobs
|
||||
WHERE
|
||||
id = ANY($1 :: uuid [ ])
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetProvisionerJobsByIDs(ctx context.Context, ids []uuid.UUID) ([]ProvisionerJob, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getProvisionerJobsByIDs, pq.Array(ids))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ProvisionerJob
|
||||
for rows.Next() {
|
||||
var i ProvisionerJob
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.StartedAt,
|
||||
&i.CanceledAt,
|
||||
&i.CompletedAt,
|
||||
&i.Error,
|
||||
&i.OrganizationID,
|
||||
&i.InitiatorID,
|
||||
&i.Provisioner,
|
||||
&i.StorageMethod,
|
||||
&i.Type,
|
||||
&i.Input,
|
||||
&i.WorkerID,
|
||||
&i.FileID,
|
||||
&i.Tags,
|
||||
&i.ErrorCode,
|
||||
&i.TraceMetadata,
|
||||
&i.JobStatus,
|
||||
&i.LogsLength,
|
||||
&i.LogsOverflowed,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProvisionerJobsByIDsWithQueuePosition = `-- name: GetProvisionerJobsByIDsWithQueuePosition :many
|
||||
WITH filtered_provisioner_jobs AS (
|
||||
-- Step 1: Filter provisioner_jobs
|
||||
@@ -14702,17 +14349,6 @@ func (q *sqlQuerier) GetAnnouncementBanners(ctx context.Context) (string, error)
|
||||
return value, err
|
||||
}
|
||||
|
||||
const getAppSecurityKey = `-- name: GetAppSecurityKey :one
|
||||
SELECT value FROM site_configs WHERE key = 'app_signing_key'
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetAppSecurityKey(ctx context.Context) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAppSecurityKey)
|
||||
var value string
|
||||
err := row.Scan(&value)
|
||||
return value, err
|
||||
}
|
||||
|
||||
const getApplicationName = `-- name: GetApplicationName :one
|
||||
SELECT value FROM site_configs WHERE key = 'application_name'
|
||||
`
|
||||
@@ -14736,17 +14372,6 @@ func (q *sqlQuerier) GetChatSystemPrompt(ctx context.Context) (string, error) {
|
||||
return chat_system_prompt, err
|
||||
}
|
||||
|
||||
const getCoordinatorResumeTokenSigningKey = `-- name: GetCoordinatorResumeTokenSigningKey :one
|
||||
SELECT value FROM site_configs WHERE key = 'coordinator_resume_token_signing_key'
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetCoordinatorResumeTokenSigningKey(ctx context.Context) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getCoordinatorResumeTokenSigningKey)
|
||||
var value string
|
||||
err := row.Scan(&value)
|
||||
return value, err
|
||||
}
|
||||
|
||||
const getDERPMeshKey = `-- name: GetDERPMeshKey :one
|
||||
SELECT value FROM site_configs WHERE key = 'derp_mesh_key'
|
||||
`
|
||||
@@ -14850,17 +14475,6 @@ func (q *sqlQuerier) GetOAuth2GithubDefaultEligible(ctx context.Context) (bool,
|
||||
return column_1, err
|
||||
}
|
||||
|
||||
const getOAuthSigningKey = `-- name: GetOAuthSigningKey :one
|
||||
SELECT value FROM site_configs WHERE key = 'oauth_signing_key'
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetOAuthSigningKey(ctx context.Context) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getOAuthSigningKey)
|
||||
var value string
|
||||
err := row.Scan(&value)
|
||||
return value, err
|
||||
}
|
||||
|
||||
const getPrebuildsSettings = `-- name: GetPrebuildsSettings :one
|
||||
SELECT
|
||||
COALESCE((SELECT value FROM site_configs WHERE key = 'prebuilds_settings'), '{}') :: text AS prebuilds_settings
|
||||
@@ -14930,16 +14544,6 @@ func (q *sqlQuerier) UpsertAnnouncementBanners(ctx context.Context, value string
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertAppSecurityKey = `-- name: UpsertAppSecurityKey :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ('app_signing_key', $1)
|
||||
ON CONFLICT (key) DO UPDATE set value = $1 WHERE site_configs.key = 'app_signing_key'
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) UpsertAppSecurityKey(ctx context.Context, value string) error {
|
||||
_, err := q.db.ExecContext(ctx, upsertAppSecurityKey, value)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertApplicationName = `-- name: UpsertApplicationName :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ('application_name', $1)
|
||||
ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'application_name'
|
||||
@@ -14960,16 +14564,6 @@ func (q *sqlQuerier) UpsertChatSystemPrompt(ctx context.Context, value string) e
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertCoordinatorResumeTokenSigningKey = `-- name: UpsertCoordinatorResumeTokenSigningKey :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ('coordinator_resume_token_signing_key', $1)
|
||||
ON CONFLICT (key) DO UPDATE set value = $1 WHERE site_configs.key = 'coordinator_resume_token_signing_key'
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) UpsertCoordinatorResumeTokenSigningKey(ctx context.Context, value string) error {
|
||||
_, err := q.db.ExecContext(ctx, upsertCoordinatorResumeTokenSigningKey, value)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertDefaultProxy = `-- name: UpsertDefaultProxy :exec
|
||||
INSERT INTO site_configs (key, value)
|
||||
VALUES
|
||||
@@ -15055,16 +14649,6 @@ func (q *sqlQuerier) UpsertOAuth2GithubDefaultEligible(ctx context.Context, elig
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertOAuthSigningKey = `-- name: UpsertOAuthSigningKey :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ('oauth_signing_key', $1)
|
||||
ON CONFLICT (key) DO UPDATE set value = $1 WHERE site_configs.key = 'oauth_signing_key'
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) UpsertOAuthSigningKey(ctx context.Context, value string) error {
|
||||
_, err := q.db.ExecContext(ctx, upsertOAuthSigningKey, value)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertPrebuildsSettings = `-- name: UpsertPrebuildsSettings :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ('prebuilds_settings', $1)
|
||||
ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'prebuilds_settings'
|
||||
@@ -17383,21 +16967,6 @@ func (q *sqlQuerier) GetTemplateVersionByTemplateIDAndName(ctx context.Context,
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTemplateVersionHasAITask = `-- name: GetTemplateVersionHasAITask :one
|
||||
SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM template_versions
|
||||
WHERE id = $1 AND has_ai_task = TRUE
|
||||
)
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetTemplateVersionHasAITask(ctx context.Context, id uuid.UUID) (bool, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTemplateVersionHasAITask, id)
|
||||
var exists bool
|
||||
err := row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
const getTemplateVersionsByIDs = `-- name: GetTemplateVersionsByIDs :many
|
||||
SELECT
|
||||
id, template_id, organization_id, created_at, updated_at, name, readme, job_id, created_by, external_auth_providers, message, archived, source_example_id, has_ai_task, has_external_agent, created_by_avatar_url, created_by_username, created_by_name
|
||||
@@ -18502,38 +18071,6 @@ func (q *sqlQuerier) UpdateUserLink(ctx context.Context, arg UpdateUserLinkParam
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateUserLinkedID = `-- name: UpdateUserLinkedID :one
|
||||
UPDATE
|
||||
user_links
|
||||
SET
|
||||
linked_id = $1
|
||||
WHERE
|
||||
user_id = $2 AND login_type = $3 RETURNING user_id, login_type, linked_id, oauth_access_token, oauth_refresh_token, oauth_expiry, oauth_access_token_key_id, oauth_refresh_token_key_id, claims
|
||||
`
|
||||
|
||||
type UpdateUserLinkedIDParams struct {
|
||||
LinkedID string `db:"linked_id" json:"linked_id"`
|
||||
UserID uuid.UUID `db:"user_id" json:"user_id"`
|
||||
LoginType LoginType `db:"login_type" json:"login_type"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) UpdateUserLinkedID(ctx context.Context, arg UpdateUserLinkedIDParams) (UserLink, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateUserLinkedID, arg.LinkedID, arg.UserID, arg.LoginType)
|
||||
var i UserLink
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.LoginType,
|
||||
&i.LinkedID,
|
||||
&i.OAuthAccessToken,
|
||||
&i.OAuthRefreshToken,
|
||||
&i.OAuthExpiry,
|
||||
&i.OAuthAccessTokenKeyID,
|
||||
&i.OAuthRefreshTokenKeyID,
|
||||
&i.Claims,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createUserSecret = `-- name: CreateUserSecret :one
|
||||
INSERT INTO user_secrets (
|
||||
id,
|
||||
@@ -22150,48 +21687,6 @@ func (q *sqlQuerier) DeleteOldWorkspaceAgentStats(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const getDeploymentDAUs = `-- name: GetDeploymentDAUs :many
|
||||
SELECT
|
||||
(created_at at TIME ZONE cast($1::integer as text))::date as date,
|
||||
user_id
|
||||
FROM
|
||||
workspace_agent_stats
|
||||
WHERE
|
||||
connection_count > 0
|
||||
GROUP BY
|
||||
date, user_id
|
||||
ORDER BY
|
||||
date ASC
|
||||
`
|
||||
|
||||
type GetDeploymentDAUsRow struct {
|
||||
Date time.Time `db:"date" json:"date"`
|
||||
UserID uuid.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) GetDeploymentDAUs(ctx context.Context, tzOffset int32) ([]GetDeploymentDAUsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getDeploymentDAUs, tzOffset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetDeploymentDAUsRow
|
||||
for rows.Next() {
|
||||
var i GetDeploymentDAUsRow
|
||||
if err := rows.Scan(&i.Date, &i.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getDeploymentWorkspaceAgentStats = `-- name: GetDeploymentWorkspaceAgentStats :one
|
||||
WITH stats AS (
|
||||
SELECT
|
||||
@@ -22330,54 +21825,6 @@ func (q *sqlQuerier) GetDeploymentWorkspaceAgentUsageStats(ctx context.Context,
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTemplateDAUs = `-- name: GetTemplateDAUs :many
|
||||
SELECT
|
||||
(created_at at TIME ZONE cast($2::integer as text))::date as date,
|
||||
user_id
|
||||
FROM
|
||||
workspace_agent_stats
|
||||
WHERE
|
||||
template_id = $1 AND
|
||||
connection_count > 0
|
||||
GROUP BY
|
||||
date, user_id
|
||||
ORDER BY
|
||||
date ASC
|
||||
`
|
||||
|
||||
type GetTemplateDAUsParams struct {
|
||||
TemplateID uuid.UUID `db:"template_id" json:"template_id"`
|
||||
TzOffset int32 `db:"tz_offset" json:"tz_offset"`
|
||||
}
|
||||
|
||||
type GetTemplateDAUsRow struct {
|
||||
Date time.Time `db:"date" json:"date"`
|
||||
UserID uuid.UUID `db:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) GetTemplateDAUs(ctx context.Context, arg GetTemplateDAUsParams) ([]GetTemplateDAUsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getTemplateDAUs, arg.TemplateID, arg.TzOffset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetTemplateDAUsRow
|
||||
for rows.Next() {
|
||||
var i GetTemplateDAUsRow
|
||||
if err := rows.Scan(&i.Date, &i.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getWorkspaceAgentStats = `-- name: GetWorkspaceAgentStats :many
|
||||
WITH agent_stats AS (
|
||||
SELECT
|
||||
@@ -23589,44 +23036,6 @@ func (q *sqlQuerier) GetWorkspaceBuildParameters(ctx context.Context, workspaceB
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getWorkspaceBuildParametersByBuildIDs = `-- name: GetWorkspaceBuildParametersByBuildIDs :many
|
||||
SELECT
|
||||
workspace_build_parameters.workspace_build_id, workspace_build_parameters.name, workspace_build_parameters.value
|
||||
FROM
|
||||
workspace_build_parameters
|
||||
JOIN
|
||||
workspace_builds ON workspace_builds.id = workspace_build_parameters.workspace_build_id
|
||||
JOIN
|
||||
workspaces ON workspaces.id = workspace_builds.workspace_id
|
||||
WHERE
|
||||
workspace_build_parameters.workspace_build_id = ANY($1 :: uuid[])
|
||||
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaceBuildParametersByBuildIDs
|
||||
-- @authorize_filter
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetWorkspaceBuildParametersByBuildIDs(ctx context.Context, workspaceBuildIds []uuid.UUID) ([]WorkspaceBuildParameter, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getWorkspaceBuildParametersByBuildIDs, pq.Array(workspaceBuildIds))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []WorkspaceBuildParameter
|
||||
for rows.Next() {
|
||||
var i WorkspaceBuildParameter
|
||||
if err := rows.Scan(&i.WorkspaceBuildID, &i.Name, &i.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const insertWorkspaceBuildParameters = `-- name: InsertWorkspaceBuildParameters :exec
|
||||
INSERT INTO
|
||||
workspace_build_parameters (workspace_build_id, name, value)
|
||||
|
||||
Reference in New Issue
Block a user