Files
lincodex/backend/internal/adapter/secondary/postgres/sqlc/invitation_pending.sql.go
T

38 lines
1.1 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: invitation_pending.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const countPendingNeedInvitations = `-- name: CountPendingNeedInvitations :one
SELECT count(*)::bigint AS pending
FROM invitations
WHERE
organization_id = $1
AND need_id = $2
AND state IN ('delivered', 'viewed', 'counter')
`
type CountPendingNeedInvitationsParams struct {
OrganizationID pgtype.UUID
NeedID pgtype.UUID
}
// Counts the invitations of one organization need that wait for an answer:
// delivered, viewed, or the planned counter offer. The send counts them under
// the organization lock, which every send takes first, so no other send can
// add a waiting invitation between the count and its own delivery.
func (q *Queries) CountPendingNeedInvitations(ctx context.Context, arg CountPendingNeedInvitationsParams) (int64, error) {
row := q.db.QueryRow(ctx, countPendingNeedInvitations, arg.OrganizationID, arg.NeedID)
var pending int64
err := row.Scan(&pending)
return pending, err
}