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

Method CountAuthorizedConnectionLogs

coderd/database/modelqueries.go:697–743  ·  view source on GitHub ↗
(ctx context.Context, arg CountConnectionLogsParams, prepared rbac.PreparedAuthorized)

Source from the content-addressed store, hash-verified

695}
696
697func (q *sqlQuerier) CountAuthorizedConnectionLogs(ctx context.Context, arg CountConnectionLogsParams, prepared rbac.PreparedAuthorized) (int64, error) {
698 authorizedFilter, err := prepared.CompileToSQL(ctx, regosql.ConvertConfig{
699 VariableConverter: regosql.ConnectionLogConverter(),
700 })
701 if err != nil {
702 return 0, xerrors.Errorf("compile authorized filter: %w", err)
703 }
704 filtered, err := insertAuthorizedFilter(countConnectionLogs, fmt.Sprintf(" AND %s", authorizedFilter))
705 if err != nil {
706 return 0, xerrors.Errorf("insert authorized filter: %w", err)
707 }
708
709 query := fmt.Sprintf("-- name: CountAuthorizedConnectionLogs :one\n%s", filtered)
710 rows, err := q.db.QueryContext(ctx, query,
711 arg.OrganizationID,
712 arg.WorkspaceOwner,
713 arg.WorkspaceOwnerID,
714 arg.WorkspaceOwnerEmail,
715 arg.Type,
716 arg.UserID,
717 arg.Username,
718 arg.UserEmail,
719 arg.ConnectedAfter,
720 arg.ConnectedBefore,
721 arg.WorkspaceID,
722 arg.ConnectionID,
723 arg.Status,
724 arg.CountCap,
725 )
726 if err != nil {
727 return 0, err
728 }
729 defer rows.Close()
730 var count int64
731 for rows.Next() {
732 if err := rows.Scan(&count); err != nil {
733 return 0, err
734 }
735 }
736 if err := rows.Close(); err != nil {
737 return 0, err
738 }
739 if err := rows.Err(); err != nil {
740 return 0, err
741 }
742 return count, nil
743}
744
745type chatQuerier interface {
746 GetAuthorizedChats(ctx context.Context, arg GetChatsParams, prepared rbac.PreparedAuthorized) ([]GetChatsRow, error)

Callers

nothing calls this directly

Calls 9

ConnectionLogConverterFunction · 0.92
insertAuthorizedFilterFunction · 0.85
QueryContextMethod · 0.80
ErrMethod · 0.80
CompileToSQLMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
ErrorfMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected