feat(desktop): drop parked review flow, add publish management
SaaS 侧人工审核后才创建 publish job,desktop 不再做二次审核:移除 manual/waiting_user/parked/from_parked 状态机与 LeaseFromParked 查询, desktop client 只执行发布并新增"发布管理"页(待发布队列 / 历史 / 再次 发送)。同时抽离 @geo/publisher-platforms 共享适配器包、新增 Redis-based desktop_presence 与 publish_record_support,刷新 admin-web 发布弹窗与 媒体库;plan A / spec 文档同步口径。
This commit is contained in:
@@ -29,6 +29,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -54,6 +55,7 @@ type ClearDesktopAccountDeleteRequestedRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -77,6 +79,7 @@ func (q *Queries) ClearDesktopAccountDeleteRequested(ctx context.Context, arg Cl
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
@@ -100,6 +103,7 @@ SELECT
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -129,6 +133,7 @@ type GetDesktopAccountByDesktopIDRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -152,6 +157,7 @@ func (q *Queries) GetDesktopAccountByDesktopID(ctx context.Context, arg GetDeskt
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
@@ -175,6 +181,7 @@ SELECT
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -207,6 +214,7 @@ type GetDesktopAccountByIdentityRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -230,6 +238,7 @@ func (q *Queries) GetDesktopAccountByIdentity(ctx context.Context, arg GetDeskto
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
@@ -242,7 +251,7 @@ func (q *Queries) GetDesktopAccountByIdentity(ctx context.Context, arg GetDeskto
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listDesktopAccountsByClient = `-- name: ListDesktopAccountsByClient :many
|
||||
const listDesktopAccountsByUser = `-- name: ListDesktopAccountsByUser :many
|
||||
SELECT
|
||||
desktop_id,
|
||||
tenant_id,
|
||||
@@ -253,6 +262,7 @@ SELECT
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -263,16 +273,17 @@ SELECT
|
||||
updated_at
|
||||
FROM platform_accounts
|
||||
WHERE workspace_id = $1
|
||||
AND client_id = $2
|
||||
AND user_id = $2
|
||||
AND deleted_at IS NULL
|
||||
ORDER BY platform_id, display_name, created_at DESC
|
||||
`
|
||||
|
||||
type ListDesktopAccountsByClientParams struct {
|
||||
WorkspaceID int64 `json:"workspace_id"`
|
||||
ClientID pgtype.UUID `json:"client_id"`
|
||||
type ListDesktopAccountsByUserParams struct {
|
||||
WorkspaceID int64 `json:"workspace_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
type ListDesktopAccountsByClientRow struct {
|
||||
type ListDesktopAccountsByUserRow struct {
|
||||
DesktopID pgtype.UUID `json:"desktop_id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
WorkspaceID int64 `json:"workspace_id"`
|
||||
@@ -282,6 +293,7 @@ type ListDesktopAccountsByClientRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -292,15 +304,15 @@ type ListDesktopAccountsByClientRow struct {
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListDesktopAccountsByClient(ctx context.Context, arg ListDesktopAccountsByClientParams) ([]ListDesktopAccountsByClientRow, error) {
|
||||
rows, err := q.db.Query(ctx, listDesktopAccountsByClient, arg.WorkspaceID, arg.ClientID)
|
||||
func (q *Queries) ListDesktopAccountsByUser(ctx context.Context, arg ListDesktopAccountsByUserParams) ([]ListDesktopAccountsByUserRow, error) {
|
||||
rows, err := q.db.Query(ctx, listDesktopAccountsByUser, arg.WorkspaceID, arg.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListDesktopAccountsByClientRow
|
||||
var items []ListDesktopAccountsByUserRow
|
||||
for rows.Next() {
|
||||
var i ListDesktopAccountsByClientRow
|
||||
var i ListDesktopAccountsByUserRow
|
||||
if err := rows.Scan(
|
||||
&i.DesktopID,
|
||||
&i.TenantID,
|
||||
@@ -311,6 +323,7 @@ func (q *Queries) ListDesktopAccountsByClient(ctx context.Context, arg ListDeskt
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
@@ -348,6 +361,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -373,6 +387,7 @@ type MarkDesktopAccountDeleteRequestedRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -396,6 +411,7 @@ func (q *Queries) MarkDesktopAccountDeleteRequested(ctx context.Context, arg Mar
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
@@ -433,6 +449,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -464,6 +481,7 @@ type PatchDesktopAccountRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -496,6 +514,7 @@ func (q *Queries) PatchDesktopAccount(ctx context.Context, arg PatchDesktopAccou
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
@@ -527,6 +546,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -553,6 +573,7 @@ type TombstoneDesktopAccountRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -576,6 +597,7 @@ func (q *Queries) TombstoneDesktopAccount(ctx context.Context, arg TombstoneDesk
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
@@ -598,6 +620,7 @@ INSERT INTO platform_accounts (
|
||||
platform_id,
|
||||
platform_uid,
|
||||
nickname,
|
||||
avatar_url,
|
||||
status,
|
||||
metadata_json,
|
||||
last_check_at,
|
||||
@@ -621,10 +644,11 @@ VALUES (
|
||||
$10,
|
||||
$11,
|
||||
$12,
|
||||
$8::text,
|
||||
$13,
|
||||
$11,
|
||||
$8::text,
|
||||
$14,
|
||||
$12,
|
||||
$15,
|
||||
1
|
||||
)
|
||||
ON CONFLICT (workspace_id, platform_id, platform_uid) WHERE deleted_at IS NULL
|
||||
@@ -632,6 +656,7 @@ DO UPDATE SET
|
||||
client_id = EXCLUDED.client_id,
|
||||
user_id = EXCLUDED.user_id,
|
||||
nickname = EXCLUDED.nickname,
|
||||
avatar_url = COALESCE(EXCLUDED.avatar_url, platform_accounts.avatar_url),
|
||||
status = EXCLUDED.status,
|
||||
metadata_json = COALESCE(EXCLUDED.metadata_json, platform_accounts.metadata_json),
|
||||
last_check_at = COALESCE(EXCLUDED.last_check_at, platform_accounts.last_check_at),
|
||||
@@ -645,8 +670,8 @@ DO UPDATE SET
|
||||
updated_at = now()
|
||||
WHERE platform_accounts.workspace_id = EXCLUDED.workspace_id
|
||||
AND (
|
||||
$15::bigint IS NULL
|
||||
OR platform_accounts.sync_version = $15::bigint
|
||||
$16::bigint IS NULL
|
||||
OR platform_accounts.sync_version = $16::bigint
|
||||
)
|
||||
RETURNING
|
||||
desktop_id,
|
||||
@@ -658,6 +683,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -677,6 +703,7 @@ type UpsertDesktopAccountParams struct {
|
||||
PlatformID string `json:"platform_id"`
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
LegacyStatus string `json:"legacy_status"`
|
||||
MetadataJson []byte `json:"metadata_json"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
@@ -696,6 +723,7 @@ type UpsertDesktopAccountRow struct {
|
||||
PlatformUid string `json:"platform_uid"`
|
||||
AccountFingerprint pgtype.Text `json:"account_fingerprint"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AvatarUrl pgtype.Text `json:"avatar_url"`
|
||||
Health string `json:"health"`
|
||||
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
|
||||
Tags []byte `json:"tags"`
|
||||
@@ -716,6 +744,7 @@ func (q *Queries) UpsertDesktopAccount(ctx context.Context, arg UpsertDesktopAcc
|
||||
arg.PlatformID,
|
||||
arg.PlatformUid,
|
||||
arg.DisplayName,
|
||||
arg.AvatarUrl,
|
||||
arg.LegacyStatus,
|
||||
arg.MetadataJson,
|
||||
arg.VerifiedAt,
|
||||
@@ -735,6 +764,7 @@ func (q *Queries) UpsertDesktopAccount(ctx context.Context, arg UpsertDesktopAcc
|
||||
&i.PlatformUid,
|
||||
&i.AccountFingerprint,
|
||||
&i.DisplayName,
|
||||
&i.AvatarUrl,
|
||||
&i.Health,
|
||||
&i.VerifiedAt,
|
||||
&i.Tags,
|
||||
|
||||
@@ -11,6 +11,42 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getDesktopClientByID = `-- name: GetDesktopClientByID :one
|
||||
SELECT id, tenant_id, workspace_id, user_id, token_hash, device_name, os, cpu_arch, client_version, channel, created_at, last_seen_at, last_rotated_at, revoked_at
|
||||
FROM desktop_clients
|
||||
WHERE id = $1
|
||||
AND workspace_id = $2
|
||||
AND revoked_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetDesktopClientByIDParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID int64 `json:"workspace_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetDesktopClientByID(ctx context.Context, arg GetDesktopClientByIDParams) (DesktopClient, error) {
|
||||
row := q.db.QueryRow(ctx, getDesktopClientByID, arg.ID, arg.WorkspaceID)
|
||||
var i DesktopClient
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.TenantID,
|
||||
&i.WorkspaceID,
|
||||
&i.UserID,
|
||||
&i.TokenHash,
|
||||
&i.DeviceName,
|
||||
&i.Os,
|
||||
&i.CpuArch,
|
||||
&i.ClientVersion,
|
||||
&i.Channel,
|
||||
&i.CreatedAt,
|
||||
&i.LastSeenAt,
|
||||
&i.LastRotatedAt,
|
||||
&i.RevokedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getDesktopClientByTokenHash = `-- name: GetDesktopClientByTokenHash :one
|
||||
SELECT id, tenant_id, workspace_id, user_id, token_hash, device_name, os, cpu_arch, client_version, channel, created_at, last_seen_at, last_rotated_at, revoked_at
|
||||
FROM desktop_clients
|
||||
@@ -163,6 +199,19 @@ VALUES (
|
||||
$9,
|
||||
$10
|
||||
)
|
||||
ON CONFLICT (id) DO UPDATE
|
||||
SET tenant_id = EXCLUDED.tenant_id,
|
||||
workspace_id = EXCLUDED.workspace_id,
|
||||
user_id = EXCLUDED.user_id,
|
||||
token_hash = EXCLUDED.token_hash,
|
||||
device_name = EXCLUDED.device_name,
|
||||
os = EXCLUDED.os,
|
||||
cpu_arch = EXCLUDED.cpu_arch,
|
||||
client_version = EXCLUDED.client_version,
|
||||
channel = EXCLUDED.channel,
|
||||
last_seen_at = now(),
|
||||
last_rotated_at = now(),
|
||||
revoked_at = NULL
|
||||
RETURNING id, tenant_id, workspace_id, user_id, token_hash, device_name, os, cpu_arch, client_version, channel, created_at, last_seen_at, last_rotated_at, revoked_at
|
||||
`
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ SET status = 'aborted',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $2
|
||||
AND target_client_id = $3
|
||||
AND status IN ('queued', 'waiting_user')
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
AND status = 'queued'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type CancelDesktopTaskByClientParams struct {
|
||||
@@ -52,7 +51,6 @@ func (q *Queries) CancelDesktopTaskByClient(ctx context.Context, arg CancelDeskt
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -68,12 +66,11 @@ SET status = 'aborted',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $2
|
||||
AND lease_token_hash = $3
|
||||
AND status = 'in_progress'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type CancelDesktopTaskByLeaseParams struct {
|
||||
@@ -102,7 +99,6 @@ func (q *Queries) CancelDesktopTaskByLease(ctx context.Context, arg CancelDeskto
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -119,12 +115,11 @@ SET status = $1,
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $4
|
||||
AND lease_token_hash = $5
|
||||
AND status = 'in_progress'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type CompleteDesktopTaskParams struct {
|
||||
@@ -161,7 +156,6 @@ func (q *Queries) CompleteDesktopTask(ctx context.Context, arg CompleteDesktopTa
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -240,8 +234,7 @@ INSERT INTO desktop_tasks (
|
||||
kind,
|
||||
payload,
|
||||
status,
|
||||
dedup_key,
|
||||
parked_reason
|
||||
dedup_key
|
||||
)
|
||||
VALUES (
|
||||
$1,
|
||||
@@ -254,10 +247,9 @@ VALUES (
|
||||
$8,
|
||||
$9,
|
||||
$10,
|
||||
$11,
|
||||
$12
|
||||
$11
|
||||
)
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type CreateDesktopTaskParams struct {
|
||||
@@ -272,7 +264,6 @@ type CreateDesktopTaskParams struct {
|
||||
Payload []byte `json:"payload"`
|
||||
Status string `json:"status"`
|
||||
DedupKey pgtype.Text `json:"dedup_key"`
|
||||
ParkedReason pgtype.Text `json:"parked_reason"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateDesktopTask(ctx context.Context, arg CreateDesktopTaskParams) (DesktopTask, error) {
|
||||
@@ -288,7 +279,6 @@ func (q *Queries) CreateDesktopTask(ctx context.Context, arg CreateDesktopTaskPa
|
||||
arg.Payload,
|
||||
arg.Status,
|
||||
arg.DedupKey,
|
||||
arg.ParkedReason,
|
||||
)
|
||||
var i DesktopTask
|
||||
err := row.Scan(
|
||||
@@ -308,7 +298,6 @@ func (q *Queries) CreateDesktopTask(ctx context.Context, arg CreateDesktopTaskPa
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -370,7 +359,7 @@ SET lease_expires_at = now() + interval '10 minutes',
|
||||
WHERE desktop_id = $1
|
||||
AND lease_token_hash = $2
|
||||
AND status = 'in_progress'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type ExtendDesktopTaskLeaseParams struct {
|
||||
@@ -398,7 +387,6 @@ func (q *Queries) ExtendDesktopTaskLease(ctx context.Context, arg ExtendDesktopT
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -434,7 +422,7 @@ func (q *Queries) FinishDesktopTaskAttempt(ctx context.Context, arg FinishDeskto
|
||||
}
|
||||
|
||||
const getDesktopTaskByDesktopID = `-- name: GetDesktopTaskByDesktopID :one
|
||||
SELECT id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
SELECT id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
FROM desktop_tasks
|
||||
WHERE desktop_id = $1
|
||||
AND workspace_id = $2
|
||||
@@ -466,7 +454,6 @@ func (q *Queries) GetDesktopTaskByDesktopID(ctx context.Context, arg GetDesktopT
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -495,11 +482,10 @@ SET active_attempt_id = $1,
|
||||
lease_expires_at = now() + interval '10 minutes',
|
||||
status = 'in_progress',
|
||||
attempts = t.attempts + 1,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
FROM candidate
|
||||
WHERE t.desktop_id = candidate.desktop_id
|
||||
RETURNING t.id, t.desktop_id, t.job_id, t.tenant_id, t.workspace_id, t.target_account_id, t.target_client_id, t.platform_id, t.kind, t.payload, t.status, t.dedup_key, t.active_attempt_id, t.lease_token_hash, t.lease_expires_at, t.attempts, t.parked_reason, t.result, t.error, t.created_at, t.updated_at
|
||||
RETURNING t.id, t.desktop_id, t.job_id, t.tenant_id, t.workspace_id, t.target_account_id, t.target_client_id, t.platform_id, t.kind, t.payload, t.status, t.dedup_key, t.active_attempt_id, t.lease_token_hash, t.lease_expires_at, t.attempts, t.result, t.error, t.created_at, t.updated_at
|
||||
`
|
||||
|
||||
type LeaseNextQueuedDesktopTaskParams struct {
|
||||
@@ -534,64 +520,6 @@ func (q *Queries) LeaseNextQueuedDesktopTask(ctx context.Context, arg LeaseNextQ
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const leaseParkedDesktopTask = `-- name: LeaseParkedDesktopTask :one
|
||||
UPDATE desktop_tasks
|
||||
SET active_attempt_id = $1,
|
||||
lease_token_hash = $2,
|
||||
lease_expires_at = now() + interval '10 minutes',
|
||||
status = 'in_progress',
|
||||
attempts = attempts + 1,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $3
|
||||
AND target_client_id = $4
|
||||
AND status = 'waiting_user'
|
||||
AND active_attempt_id IS NULL
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type LeaseParkedDesktopTaskParams struct {
|
||||
AttemptID pgtype.UUID `json:"attempt_id"`
|
||||
LeaseTokenHash []byte `json:"lease_token_hash"`
|
||||
DesktopID pgtype.UUID `json:"desktop_id"`
|
||||
ClientID pgtype.UUID `json:"client_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) LeaseParkedDesktopTask(ctx context.Context, arg LeaseParkedDesktopTaskParams) (DesktopTask, error) {
|
||||
row := q.db.QueryRow(ctx, leaseParkedDesktopTask,
|
||||
arg.AttemptID,
|
||||
arg.LeaseTokenHash,
|
||||
arg.DesktopID,
|
||||
arg.ClientID,
|
||||
)
|
||||
var i DesktopTask
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.DesktopID,
|
||||
&i.JobID,
|
||||
&i.TenantID,
|
||||
&i.WorkspaceID,
|
||||
&i.TargetAccountID,
|
||||
&i.TargetClientID,
|
||||
&i.PlatformID,
|
||||
&i.Kind,
|
||||
&i.Payload,
|
||||
&i.Status,
|
||||
&i.DedupKey,
|
||||
&i.ActiveAttemptID,
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -607,12 +535,11 @@ SET active_attempt_id = $1,
|
||||
lease_expires_at = now() + interval '10 minutes',
|
||||
status = 'in_progress',
|
||||
attempts = attempts + 1,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $3
|
||||
AND target_client_id = $4
|
||||
AND status = 'queued'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type LeaseQueuedDesktopTaskByDesktopIDParams struct {
|
||||
@@ -647,7 +574,6 @@ func (q *Queries) LeaseQueuedDesktopTaskByDesktopID(ctx context.Context, arg Lea
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -663,11 +589,10 @@ SET status = 'unknown',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE target_client_id = $2
|
||||
AND workspace_id = $3
|
||||
AND status IN ('waiting_user', 'in_progress')
|
||||
AND status = 'in_progress'
|
||||
`
|
||||
|
||||
type MarkDesktopTasksUnknownByClientParams struct {
|
||||
@@ -684,55 +609,6 @@ func (q *Queries) MarkDesktopTasksUnknownByClient(ctx context.Context, arg MarkD
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const parkDesktopTask = `-- name: ParkDesktopTask :one
|
||||
UPDATE desktop_tasks
|
||||
SET status = 'waiting_user',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = $1,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $2
|
||||
AND lease_token_hash = $3
|
||||
AND status = 'in_progress'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type ParkDesktopTaskParams struct {
|
||||
ParkedReason pgtype.Text `json:"parked_reason"`
|
||||
DesktopID pgtype.UUID `json:"desktop_id"`
|
||||
LeaseTokenHash []byte `json:"lease_token_hash"`
|
||||
}
|
||||
|
||||
func (q *Queries) ParkDesktopTask(ctx context.Context, arg ParkDesktopTaskParams) (DesktopTask, error) {
|
||||
row := q.db.QueryRow(ctx, parkDesktopTask, arg.ParkedReason, arg.DesktopID, arg.LeaseTokenHash)
|
||||
var i DesktopTask
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.DesktopID,
|
||||
&i.JobID,
|
||||
&i.TenantID,
|
||||
&i.WorkspaceID,
|
||||
&i.TargetAccountID,
|
||||
&i.TargetClientID,
|
||||
&i.PlatformID,
|
||||
&i.Kind,
|
||||
&i.Payload,
|
||||
&i.Status,
|
||||
&i.DedupKey,
|
||||
&i.ActiveAttemptID,
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const reconcileDesktopTask = `-- name: ReconcileDesktopTask :one
|
||||
UPDATE desktop_tasks
|
||||
SET status = CASE
|
||||
@@ -747,13 +623,12 @@ SET status = CASE
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
attempts = attempts + CASE WHEN $1::text = 'retry' THEN 1 ELSE 0 END,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $4
|
||||
AND workspace_id = $5
|
||||
AND status = 'unknown'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type ReconcileDesktopTaskParams struct {
|
||||
@@ -790,7 +665,6 @@ func (q *Queries) ReconcileDesktopTask(ctx context.Context, arg ReconcileDesktop
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
@@ -806,12 +680,11 @@ SET status = 'aborted',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = $2
|
||||
AND workspace_id = $3
|
||||
AND status IN ('queued', 'waiting_user')
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, parked_reason, result, error, created_at, updated_at
|
||||
AND status = 'queued'
|
||||
RETURNING id, desktop_id, job_id, tenant_id, workspace_id, target_account_id, target_client_id, platform_id, kind, payload, status, dedup_key, active_attempt_id, lease_token_hash, lease_expires_at, attempts, result, error, created_at, updated_at
|
||||
`
|
||||
|
||||
type TenantCancelDesktopTaskParams struct {
|
||||
@@ -840,7 +713,6 @@ func (q *Queries) TenantCancelDesktopTask(ctx context.Context, arg TenantCancelD
|
||||
&i.LeaseTokenHash,
|
||||
&i.LeaseExpiresAt,
|
||||
&i.Attempts,
|
||||
&i.ParkedReason,
|
||||
&i.Result,
|
||||
&i.Error,
|
||||
&i.CreatedAt,
|
||||
|
||||
@@ -166,7 +166,6 @@ type DesktopTask struct {
|
||||
LeaseTokenHash []byte `json:"lease_token_hash"`
|
||||
LeaseExpiresAt pgtype.Timestamptz `json:"lease_expires_at"`
|
||||
Attempts int32 `json:"attempts"`
|
||||
ParkedReason pgtype.Text `json:"parked_reason"`
|
||||
Result []byte `json:"result"`
|
||||
Error []byte `json:"error"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
|
||||
@@ -64,6 +64,7 @@ type Querier interface {
|
||||
GetCurrentBalance(ctx context.Context, arg GetCurrentBalanceParams) (int32, error)
|
||||
GetDesktopAccountByDesktopID(ctx context.Context, arg GetDesktopAccountByDesktopIDParams) (GetDesktopAccountByDesktopIDRow, error)
|
||||
GetDesktopAccountByIdentity(ctx context.Context, arg GetDesktopAccountByIdentityParams) (GetDesktopAccountByIdentityRow, error)
|
||||
GetDesktopClientByID(ctx context.Context, arg GetDesktopClientByIDParams) (DesktopClient, error)
|
||||
GetDesktopClientByTokenHash(ctx context.Context, tokenHash []byte) (DesktopClient, error)
|
||||
GetDesktopTaskByDesktopID(ctx context.Context, arg GetDesktopTaskByDesktopIDParams) (DesktopTask, error)
|
||||
GetImageAsset(ctx context.Context, arg GetImageAssetParams) (GetImageAssetRow, error)
|
||||
@@ -101,7 +102,6 @@ type Querier interface {
|
||||
// Cross-tenant aggregation for KOL dashboard.
|
||||
KolUsageCountByPackage(ctx context.Context, packageIds []int64) ([]KolUsageCountByPackageRow, error)
|
||||
LeaseNextQueuedDesktopTask(ctx context.Context, arg LeaseNextQueuedDesktopTaskParams) (DesktopTask, error)
|
||||
LeaseParkedDesktopTask(ctx context.Context, arg LeaseParkedDesktopTaskParams) (DesktopTask, error)
|
||||
LeaseQueuedDesktopTaskByDesktopID(ctx context.Context, arg LeaseQueuedDesktopTaskByDesktopIDParams) (DesktopTask, error)
|
||||
ListActiveImagesByFolder(ctx context.Context, arg ListActiveImagesByFolderParams) ([]ListActiveImagesByFolderRow, error)
|
||||
ListActiveKolPromptsByPackage(ctx context.Context, arg ListActiveKolPromptsByPackageParams) ([]ListActiveKolPromptsByPackageRow, error)
|
||||
@@ -112,7 +112,7 @@ type Querier interface {
|
||||
ListArticles(ctx context.Context, arg ListArticlesParams) ([]ListArticlesRow, error)
|
||||
ListBrands(ctx context.Context, tenantID int64) ([]ListBrandsRow, error)
|
||||
ListCompetitors(ctx context.Context, arg ListCompetitorsParams) ([]ListCompetitorsRow, error)
|
||||
ListDesktopAccountsByClient(ctx context.Context, arg ListDesktopAccountsByClientParams) ([]ListDesktopAccountsByClientRow, error)
|
||||
ListDesktopAccountsByUser(ctx context.Context, arg ListDesktopAccountsByUserParams) ([]ListDesktopAccountsByUserRow, error)
|
||||
ListDesktopClientsByWorkspace(ctx context.Context, workspaceID int64) ([]DesktopClient, error)
|
||||
ListImageAssets(ctx context.Context, arg ListImageAssetsParams) ([]ListImageAssetsRow, error)
|
||||
ListImageFolders(ctx context.Context, tenantID int64) ([]ListImageFoldersRow, error)
|
||||
@@ -152,7 +152,6 @@ type Querier interface {
|
||||
MarkKolUsageFailed(ctx context.Context, arg MarkKolUsageFailedParams) error
|
||||
MarkKolUsageFailedByTask(ctx context.Context, arg MarkKolUsageFailedByTaskParams) error
|
||||
NextKolPromptRevisionNo(ctx context.Context, arg NextKolPromptRevisionNoParams) (int32, error)
|
||||
ParkDesktopTask(ctx context.Context, arg ParkDesktopTaskParams) (DesktopTask, error)
|
||||
PatchDesktopAccount(ctx context.Context, arg PatchDesktopAccountParams) (PatchDesktopAccountRow, error)
|
||||
ReconcileDesktopTask(ctx context.Context, arg ReconcileDesktopTaskParams) (DesktopTask, error)
|
||||
RefundReservation(ctx context.Context, arg RefundReservationParams) error
|
||||
|
||||
Reference in New Issue
Block a user