Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0fddf5

Browse files
committed
PR comments
1 parentce4b914 commita0fddf5

File tree

14 files changed

+250
-79
lines changed

14 files changed

+250
-79
lines changed

‎coderd/apidoc/docs.go‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5802,5 +5802,7 @@ func (q *querier) CountAuthorizedConnectionLogs(ctx context.Context, arg databas
58025802

58035803
func (q*querier)ListAuthorizedAIBridgeInterceptions(ctx context.Context,arg database.ListAIBridgeInterceptionsParams,_ rbac.PreparedAuthorized) ([]database.AIBridgeInterception,error) {
58045804
// TODO: Delete this function, all ListAIBridgeInterceptions should be authorized. For now just call ListAIBridgeInterceptions on the authz querier.
5805+
// This cannot be deleted for now because it's included in the
5806+
// database.Store interface, so dbauthz needs to implement it.
58055807
returnq.ListAIBridgeInterceptions(ctx,arg)
58065808
}

‎coderd/database/dump.sql‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DROPINDEX IF EXISTS idx_aibridge_interceptions_started_id_desc;
2+
3+
DROPINDEX IF EXISTS idx_aibridge_interceptions_provider;
4+
5+
DROPINDEX IF EXISTS idx_aibridge_interceptions_model;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- This is used for consistent cursor pagination.
2+
CREATEINDEXIF NOT EXISTS idx_aibridge_interceptions_started_id_desc
3+
ON aibridge_interceptions (started_atDESC, idDESC);
4+
5+
CREATEINDEXIF NOT EXISTS idx_aibridge_interceptions_provider
6+
ON aibridge_interceptions (provider);
7+
8+
CREATEINDEXIF NOT EXISTS idx_aibridge_interceptions_model
9+
ON aibridge_interceptions (model);

‎coderd/database/modelqueries.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ func (q *sqlQuerier) ListAuthorizedAIBridgeInterceptions(ctx context.Context, ar
785785
arg.InitiatorID,
786786
arg.Provider,
787787
arg.Model,
788-
arg.Offset,
788+
arg.AfterID,
789789
arg.Limit,
790790
)
791791
iferr!=nil {

‎coderd/database/queries.sql.go‎

Lines changed: 59 additions & 8 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/aibridge.sql‎

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,49 @@ INSERT INTO aibridge_tool_usages (
3131
RETURNING*;
3232

3333
-- name: GetAIBridgeInterceptionByID :one
34-
SELECT*FROM aibridge_interceptionsWHERE id= @id::uuid;
34+
SELECT
35+
*
36+
FROM
37+
aibridge_interceptions
38+
WHERE
39+
id= @id::uuid;
3540

3641
-- name: GetAIBridgeInterceptions :many
37-
SELECT*FROM aibridge_interceptions;
42+
SELECT
43+
*
44+
FROM
45+
aibridge_interceptions;
3846

3947
-- name: GetAIBridgeTokenUsagesByInterceptionID :many
40-
SELECT*FROM aibridge_token_usagesWHERE interception_id= @interception_id::uuid;
48+
SELECT
49+
*
50+
FROM
51+
aibridge_token_usagesWHERE interception_id= @interception_id::uuid
52+
ORDER BY
53+
created_atDESC,
54+
idDESC;
4155

4256
-- name: GetAIBridgeUserPromptsByInterceptionID :many
43-
SELECT*FROM aibridge_user_promptsWHERE interception_id= @interception_id::uuid;
57+
SELECT
58+
*
59+
FROM
60+
aibridge_user_prompts
61+
WHERE
62+
interception_id= @interception_id::uuid
63+
ORDER BY
64+
created_atDESC,
65+
idDESC;
4466

4567
-- name: GetAIBridgeToolUsagesByInterceptionID :many
46-
SELECT*FROM aibridge_tool_usagesWHERE interception_id= @interception_id::uuid;
68+
SELECT
69+
*
70+
FROM
71+
aibridge_tool_usages
72+
WHERE
73+
interception_id= @interception_id::uuid
74+
ORDER BY
75+
created_atDESC,
76+
idDESC;
4777

4878
-- name: ListAIBridgeInterceptions :many
4979
SELECT
@@ -75,13 +105,25 @@ WHERE
75105
WHEN @model::text!='' THENaibridge_interceptions.model= @model::text
76106
ELSE true
77107
END
108+
-- Cursor pagination
109+
AND CASE
110+
WHEN @after_id::uuid!='00000000-0000-0000-0000-000000000000'::uuid THEN (
111+
-- The pagination cursor is the last ID of the previous page.
112+
-- The query is ordered by the started_at field, so select all
113+
-- rows before the cursor and before the after_id UUID.
114+
(aibridge_interceptions.started_at,aibridge_interceptions.id)< (
115+
(SELECT started_atFROM aibridge_interceptionsWHERE id= @after_id),
116+
@after_id::uuid
117+
)
118+
)
119+
ELSE true
120+
END
78121
-- Authorize Filter clause will be injected below in ListAuthorizedAIBridgeInterceptions
79122
-- @authorize_filter
80123
ORDER BY
81124
aibridge_interceptions.started_atDESC,
82125
aibridge_interceptions.idDESC
83126
LIMIT COALESCE(NULLIF(@limit_::integer,0),100)
84-
OFFSET @offset_
85127
;
86128

87129
-- name: ListAIBridgeTokenUsagesByInterceptionIDs :many
@@ -90,20 +132,29 @@ SELECT
90132
FROM
91133
aibridge_token_usages
92134
WHERE
93-
interception_id= ANY(@interception_ids::uuid[]);
135+
interception_id= ANY(@interception_ids::uuid[])
136+
ORDER BY
137+
created_atASC,
138+
idASC;
94139

95140
-- name: ListAIBridgeUserPromptsByInterceptionIDs :many
96141
SELECT
97142
*
98143
FROM
99144
aibridge_user_prompts
100145
WHERE
101-
interception_id= ANY(@interception_ids::uuid[]);
146+
interception_id= ANY(@interception_ids::uuid[])
147+
ORDER BY
148+
created_atASC,
149+
idASC;
102150

103151
-- name: ListAIBridgeToolUsagesByInterceptionIDs :many
104152
SELECT
105153
*
106154
FROM
107155
aibridge_tool_usages
108156
WHERE
109-
interception_id= ANY(@interception_ids::uuid[]);
157+
interception_id= ANY(@interception_ids::uuid[])
158+
ORDER BY
159+
created_atASC,
160+
idASC;

‎coderd/searchquery/search.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ func Templates(ctx context.Context, db database.Store, actorID uuid.UUID, query
308308
funcAIBridgeInterceptions(ctx context.Context,db database.Store,querystring,page codersdk.Pagination,actorID uuid.UUID) (database.ListAIBridgeInterceptionsParams, []codersdk.ValidationError) {
309309
// nolint:exhaustruct // Empty values just means "don't filter by that field".
310310
filter:= database.ListAIBridgeInterceptionsParams{
311-
// #nosec G115 - Safe conversion for pagination offset which is expected to be within int32 range
312-
Offset:int32(page.Offset),
311+
AfterID:page.AfterID,
313312
// #nosec G115 - Safe conversion for pagination limit which is expected to be within int32 range
314313
Limit:int32(page.Limit),
315314
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp