(ctx context.Context, arg CountAuditLogsParams, prepared rbac.PreparedAuthorized)
| 557 | } |
| 558 | |
| 559 | func (q *sqlQuerier) CountAuthorizedAuditLogs(ctx context.Context, arg CountAuditLogsParams, prepared rbac.PreparedAuthorized) (int64, error) { |
| 560 | authorizedFilter, err := prepared.CompileToSQL(ctx, regosql.ConvertConfig{ |
| 561 | VariableConverter: regosql.AuditLogConverter(), |
| 562 | }) |
| 563 | if err != nil { |
| 564 | return 0, xerrors.Errorf("compile authorized filter: %w", err) |
| 565 | } |
| 566 | |
| 567 | filtered, err := insertAuthorizedFilter(countAuditLogs, fmt.Sprintf(" AND %s", authorizedFilter)) |
| 568 | if err != nil { |
| 569 | return 0, xerrors.Errorf("insert authorized filter: %w", err) |
| 570 | } |
| 571 | |
| 572 | query := fmt.Sprintf("-- name: CountAuthorizedAuditLogs :one\n%s", filtered) |
| 573 | |
| 574 | rows, err := q.db.QueryContext(ctx, query, |
| 575 | arg.ResourceType, |
| 576 | arg.ResourceID, |
| 577 | arg.OrganizationID, |
| 578 | arg.ResourceTarget, |
| 579 | arg.Action, |
| 580 | arg.UserID, |
| 581 | arg.Username, |
| 582 | arg.Email, |
| 583 | arg.DateFrom, |
| 584 | arg.DateTo, |
| 585 | arg.BuildReason, |
| 586 | arg.RequestID, |
| 587 | arg.CountCap, |
| 588 | ) |
| 589 | if err != nil { |
| 590 | return 0, err |
| 591 | } |
| 592 | defer rows.Close() |
| 593 | var count int64 |
| 594 | for rows.Next() { |
| 595 | if err := rows.Scan(&count); err != nil { |
| 596 | return 0, err |
| 597 | } |
| 598 | } |
| 599 | if err := rows.Close(); err != nil { |
| 600 | return 0, err |
| 601 | } |
| 602 | if err := rows.Err(); err != nil { |
| 603 | return 0, err |
| 604 | } |
| 605 | return count, nil |
| 606 | } |
| 607 | |
| 608 | type connectionLogQuerier interface { |
| 609 | GetAuthorizedConnectionLogsOffset(ctx context.Context, arg GetConnectionLogsOffsetParams, prepared rbac.PreparedAuthorized) ([]GetConnectionLogsOffsetRow, error) |
nothing calls this directly
no test coverage detected