mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add ended_at column to aibridge_interceptions table (#20432)
Needed for marking interceptions as done (https://github.com/coder/internal/issues/1051).
This commit is contained in:
Generated
+2
-1
@@ -1055,7 +1055,8 @@ CREATE TABLE aibridge_interceptions (
|
|||||||
provider text NOT NULL,
|
provider text NOT NULL,
|
||||||
model text NOT NULL,
|
model text NOT NULL,
|
||||||
started_at timestamp with time zone NOT NULL,
|
started_at timestamp with time zone NOT NULL,
|
||||||
metadata jsonb
|
metadata jsonb,
|
||||||
|
ended_at timestamp with time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
COMMENT ON TABLE aibridge_interceptions IS 'Audit log of requests intercepted by AI Bridge';
|
COMMENT ON TABLE aibridge_interceptions IS 'Audit log of requests intercepted by AI Bridge';
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE aibridge_interceptions DROP COLUMN ended_at;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE aibridge_interceptions ADD COLUMN ended_at TIMESTAMP WITH TIME ZONE DEFAULT NULL;
|
||||||
@@ -804,6 +804,7 @@ func (q *sqlQuerier) ListAuthorizedAIBridgeInterceptions(ctx context.Context, ar
|
|||||||
&i.AIBridgeInterception.Model,
|
&i.AIBridgeInterception.Model,
|
||||||
&i.AIBridgeInterception.StartedAt,
|
&i.AIBridgeInterception.StartedAt,
|
||||||
&i.AIBridgeInterception.Metadata,
|
&i.AIBridgeInterception.Metadata,
|
||||||
|
&i.AIBridgeInterception.EndedAt,
|
||||||
&i.VisibleUser.ID,
|
&i.VisibleUser.ID,
|
||||||
&i.VisibleUser.Username,
|
&i.VisibleUser.Username,
|
||||||
&i.VisibleUser.Name,
|
&i.VisibleUser.Name,
|
||||||
|
|||||||
@@ -3613,6 +3613,7 @@ type AIBridgeInterception struct {
|
|||||||
Model string `db:"model" json:"model"`
|
Model string `db:"model" json:"model"`
|
||||||
StartedAt time.Time `db:"started_at" json:"started_at"`
|
StartedAt time.Time `db:"started_at" json:"started_at"`
|
||||||
Metadata pqtype.NullRawMessage `db:"metadata" json:"metadata"`
|
Metadata pqtype.NullRawMessage `db:"metadata" json:"metadata"`
|
||||||
|
EndedAt sql.NullTime `db:"ended_at" json:"ended_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audit log of tokens used by intercepted requests in AI Bridge
|
// Audit log of tokens used by intercepted requests in AI Bridge
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ func (q *sqlQuerier) CountAIBridgeInterceptions(ctx context.Context, arg CountAI
|
|||||||
|
|
||||||
const getAIBridgeInterceptionByID = `-- name: GetAIBridgeInterceptionByID :one
|
const getAIBridgeInterceptionByID = `-- name: GetAIBridgeInterceptionByID :one
|
||||||
SELECT
|
SELECT
|
||||||
id, initiator_id, provider, model, started_at, metadata
|
id, initiator_id, provider, model, started_at, metadata, ended_at
|
||||||
FROM
|
FROM
|
||||||
aibridge_interceptions
|
aibridge_interceptions
|
||||||
WHERE
|
WHERE
|
||||||
@@ -185,13 +185,14 @@ func (q *sqlQuerier) GetAIBridgeInterceptionByID(ctx context.Context, id uuid.UU
|
|||||||
&i.Model,
|
&i.Model,
|
||||||
&i.StartedAt,
|
&i.StartedAt,
|
||||||
&i.Metadata,
|
&i.Metadata,
|
||||||
|
&i.EndedAt,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const getAIBridgeInterceptions = `-- name: GetAIBridgeInterceptions :many
|
const getAIBridgeInterceptions = `-- name: GetAIBridgeInterceptions :many
|
||||||
SELECT
|
SELECT
|
||||||
id, initiator_id, provider, model, started_at, metadata
|
id, initiator_id, provider, model, started_at, metadata, ended_at
|
||||||
FROM
|
FROM
|
||||||
aibridge_interceptions
|
aibridge_interceptions
|
||||||
`
|
`
|
||||||
@@ -212,6 +213,7 @@ func (q *sqlQuerier) GetAIBridgeInterceptions(ctx context.Context) ([]AIBridgeIn
|
|||||||
&i.Model,
|
&i.Model,
|
||||||
&i.StartedAt,
|
&i.StartedAt,
|
||||||
&i.Metadata,
|
&i.Metadata,
|
||||||
|
&i.EndedAt,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -361,7 +363,7 @@ INSERT INTO aibridge_interceptions (
|
|||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, COALESCE($5::jsonb, '{}'::jsonb), $6
|
$1, $2, $3, $4, COALESCE($5::jsonb, '{}'::jsonb), $6
|
||||||
)
|
)
|
||||||
RETURNING id, initiator_id, provider, model, started_at, metadata
|
RETURNING id, initiator_id, provider, model, started_at, metadata, ended_at
|
||||||
`
|
`
|
||||||
|
|
||||||
type InsertAIBridgeInterceptionParams struct {
|
type InsertAIBridgeInterceptionParams struct {
|
||||||
@@ -390,6 +392,7 @@ func (q *sqlQuerier) InsertAIBridgeInterception(ctx context.Context, arg InsertA
|
|||||||
&i.Model,
|
&i.Model,
|
||||||
&i.StartedAt,
|
&i.StartedAt,
|
||||||
&i.Metadata,
|
&i.Metadata,
|
||||||
|
&i.EndedAt,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
@@ -528,7 +531,7 @@ func (q *sqlQuerier) InsertAIBridgeUserPrompt(ctx context.Context, arg InsertAIB
|
|||||||
|
|
||||||
const listAIBridgeInterceptions = `-- name: ListAIBridgeInterceptions :many
|
const listAIBridgeInterceptions = `-- name: ListAIBridgeInterceptions :many
|
||||||
SELECT
|
SELECT
|
||||||
aibridge_interceptions.id, aibridge_interceptions.initiator_id, aibridge_interceptions.provider, aibridge_interceptions.model, aibridge_interceptions.started_at, aibridge_interceptions.metadata,
|
aibridge_interceptions.id, aibridge_interceptions.initiator_id, aibridge_interceptions.provider, aibridge_interceptions.model, aibridge_interceptions.started_at, aibridge_interceptions.metadata, aibridge_interceptions.ended_at,
|
||||||
visible_users.id, visible_users.username, visible_users.name, visible_users.avatar_url
|
visible_users.id, visible_users.username, visible_users.name, visible_users.avatar_url
|
||||||
FROM
|
FROM
|
||||||
aibridge_interceptions
|
aibridge_interceptions
|
||||||
@@ -625,6 +628,7 @@ func (q *sqlQuerier) ListAIBridgeInterceptions(ctx context.Context, arg ListAIBr
|
|||||||
&i.AIBridgeInterception.Model,
|
&i.AIBridgeInterception.Model,
|
||||||
&i.AIBridgeInterception.StartedAt,
|
&i.AIBridgeInterception.StartedAt,
|
||||||
&i.AIBridgeInterception.Metadata,
|
&i.AIBridgeInterception.Metadata,
|
||||||
|
&i.AIBridgeInterception.EndedAt,
|
||||||
&i.VisibleUser.ID,
|
&i.VisibleUser.ID,
|
||||||
&i.VisibleUser.Username,
|
&i.VisibleUser.Username,
|
||||||
&i.VisibleUser.Name,
|
&i.VisibleUser.Name,
|
||||||
|
|||||||
Reference in New Issue
Block a user