MCPcopy Index your code
hub / github.com/coder/coder / AIBridgeInterceptions

Function AIBridgeInterceptions

coderd/searchquery/search.go:364–406  ·  view source on GitHub ↗
(ctx context.Context, db database.Store, query string, page codersdk.Pagination, actorID uuid.UUID)

Source from the content-addressed store, hash-verified

362}
363
364func AIBridgeInterceptions(ctx context.Context, db database.Store, query string, page codersdk.Pagination, actorID uuid.UUID) (database.ListAIBridgeInterceptionsParams, []codersdk.ValidationError) {
365 // nolint:exhaustruct // Empty values just means "don't filter by that field".
366 filter := database.ListAIBridgeInterceptionsParams{
367 AfterID: page.AfterID,
368 // #nosec G115 - Safe conversion for pagination limit which is expected to be within int32 range
369 Limit: int32(page.Limit),
370 // #nosec G115 - Safe conversion for pagination offset which is expected to be within int32 range
371 Offset: int32(page.Offset),
372 }
373
374 if query == "" {
375 return filter, nil
376 }
377
378 values, errors := searchTerms(query, func(term string, values url.Values) error {
379 // Default to the initiating user
380 values.Add("initiator", term)
381 return nil
382 })
383 if len(errors) > 0 {
384 return filter, errors
385 }
386
387 parser := httpapi.NewQueryParamParser()
388 filter.InitiatorID = parseUser(ctx, db, parser, values, "initiator", actorID)
389 filter.Provider = parser.String(values, "", "provider")
390 filter.ProviderName = parseAIProviderName(ctx, db, parser, values)
391 filter.Model = parser.String(values, "", "model")
392 filter.Client = parser.String(values, "", "client")
393
394 // Time must be between started_after and started_before.
395 filter.StartedAfter = parser.Time3339Nano(values, time.Time{}, "started_after")
396 filter.StartedBefore = parser.Time3339Nano(values, time.Time{}, "started_before")
397 if !filter.StartedBefore.IsZero() && !filter.StartedAfter.IsZero() && !filter.StartedBefore.After(filter.StartedAfter) {
398 parser.Errors = append(parser.Errors, codersdk.ValidationError{
399 Field: "started_before",
400 Detail: `Query param "started_before" has invalid value: "started_before" must be after "started_after" if set`,
401 })
402 }
403
404 parser.ErrorExcessParams(values)
405 return filter, parser.Errors
406}
407
408func AIBridgeSessions(ctx context.Context, db database.Store, query string, page codersdk.Pagination, actorID uuid.UUID, afterSessionID string) (database.ListAIBridgeSessionsParams, []codersdk.ValidationError) {
409 // nolint:exhaustruct // Empty values just means "don't filter by that field".

Callers 1

Calls 9

StringMethod · 0.95
Time3339NanoMethod · 0.95
ErrorExcessParamsMethod · 0.95
NewQueryParamParserFunction · 0.92
searchTermsFunction · 0.85
parseUserFunction · 0.85
parseAIProviderNameFunction · 0.85
AddMethod · 0.65
IsZeroMethod · 0.45

Tested by

no test coverage detected