Replace domain claims with open invoices, show monthly recurring revenue, count team organizations, and add more informative trend captions. Use standard bordered cards and add a README screenshot with reversible sample-data tooling.
285 lines
7.8 KiB
Go
285 lines
7.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: pool_provisions.sql
|
|
|
|
package entitlements
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const getActivePoolProvisionsByPoolID = `-- name: GetActivePoolProvisionsByPoolID :many
|
|
SELECT provision_id, pool_id, billing_account_id, subscription_id, purchase_id, grant_id, quantity, status, activated_at, suspended_at, ended_at, created_at, updated_at, entitlement_set_id, product_id FROM core.pool_provisions
|
|
WHERE pool_id = $1 AND status = 'active'
|
|
ORDER BY created_at ASC
|
|
`
|
|
|
|
func (q *Queries) GetActivePoolProvisionsByPoolID(ctx context.Context, poolID string) ([]PoolProvision, error) {
|
|
rows, err := q.db.QueryContext(ctx, getActivePoolProvisionsByPoolID, poolID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []PoolProvision{}
|
|
for rows.Next() {
|
|
var i PoolProvision
|
|
if err := rows.Scan(
|
|
&i.ProvisionID,
|
|
&i.PoolID,
|
|
&i.BillingAccountID,
|
|
&i.SubscriptionID,
|
|
&i.PurchaseID,
|
|
&i.GrantID,
|
|
&i.Quantity,
|
|
&i.Status,
|
|
&i.ActivatedAt,
|
|
&i.SuspendedAt,
|
|
&i.EndedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.ProductID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getLivePoolProvisionsByProductID = `-- name: GetLivePoolProvisionsByProductID :many
|
|
SELECT provision_id, pool_id, billing_account_id, subscription_id, purchase_id, grant_id, quantity, status, activated_at, suspended_at, ended_at, created_at, updated_at, entitlement_set_id, product_id FROM core.pool_provisions
|
|
WHERE product_id = $1 AND status <> 'ended'
|
|
ORDER BY created_at ASC
|
|
`
|
|
|
|
// Live (non-ended) provisions delivering a product. Tier add/remove aligns
|
|
// each of these to the product's new conferral shape.
|
|
func (q *Queries) GetLivePoolProvisionsByProductID(ctx context.Context, productID string) ([]PoolProvision, error) {
|
|
rows, err := q.db.QueryContext(ctx, getLivePoolProvisionsByProductID, productID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []PoolProvision{}
|
|
for rows.Next() {
|
|
var i PoolProvision
|
|
if err := rows.Scan(
|
|
&i.ProvisionID,
|
|
&i.PoolID,
|
|
&i.BillingAccountID,
|
|
&i.SubscriptionID,
|
|
&i.PurchaseID,
|
|
&i.GrantID,
|
|
&i.Quantity,
|
|
&i.Status,
|
|
&i.ActivatedAt,
|
|
&i.SuspendedAt,
|
|
&i.EndedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.ProductID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getLivePoolProvisionsBySubscriptionID = `-- name: GetLivePoolProvisionsBySubscriptionID :many
|
|
SELECT provision_id, pool_id, billing_account_id, subscription_id, purchase_id, grant_id, quantity, status, activated_at, suspended_at, ended_at, created_at, updated_at, entitlement_set_id, product_id FROM core.pool_provisions
|
|
WHERE subscription_id = $1 AND status <> 'ended'
|
|
ORDER BY created_at ASC
|
|
`
|
|
|
|
// Live (non-ended) provisions of a subscription, one per product. Reconcile
|
|
// diffs these against the subscription's desired-by-product line items.
|
|
func (q *Queries) GetLivePoolProvisionsBySubscriptionID(ctx context.Context, subscriptionID uuid.NullUUID) ([]PoolProvision, error) {
|
|
rows, err := q.db.QueryContext(ctx, getLivePoolProvisionsBySubscriptionID, subscriptionID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []PoolProvision{}
|
|
for rows.Next() {
|
|
var i PoolProvision
|
|
if err := rows.Scan(
|
|
&i.ProvisionID,
|
|
&i.PoolID,
|
|
&i.BillingAccountID,
|
|
&i.SubscriptionID,
|
|
&i.PurchaseID,
|
|
&i.GrantID,
|
|
&i.Quantity,
|
|
&i.Status,
|
|
&i.ActivatedAt,
|
|
&i.SuspendedAt,
|
|
&i.EndedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.ProductID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getPoolProvisionByGrantID = `-- name: GetPoolProvisionByGrantID :one
|
|
SELECT provision_id, pool_id, billing_account_id, subscription_id, purchase_id, grant_id, quantity, status, activated_at, suspended_at, ended_at, created_at, updated_at, entitlement_set_id, product_id FROM core.pool_provisions
|
|
WHERE grant_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPoolProvisionByGrantID(ctx context.Context, grantID uuid.NullUUID) (PoolProvision, error) {
|
|
row := q.db.QueryRowContext(ctx, getPoolProvisionByGrantID, grantID)
|
|
var i PoolProvision
|
|
err := row.Scan(
|
|
&i.ProvisionID,
|
|
&i.PoolID,
|
|
&i.BillingAccountID,
|
|
&i.SubscriptionID,
|
|
&i.PurchaseID,
|
|
&i.GrantID,
|
|
&i.Quantity,
|
|
&i.Status,
|
|
&i.ActivatedAt,
|
|
&i.SuspendedAt,
|
|
&i.EndedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.ProductID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPoolProvisionByProvisionID = `-- name: GetPoolProvisionByProvisionID :one
|
|
SELECT provision_id, pool_id, billing_account_id, subscription_id, purchase_id, grant_id, quantity, status, activated_at, suspended_at, ended_at, created_at, updated_at, entitlement_set_id, product_id FROM core.pool_provisions
|
|
WHERE provision_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPoolProvisionByProvisionID(ctx context.Context, provisionID string) (PoolProvision, error) {
|
|
row := q.db.QueryRowContext(ctx, getPoolProvisionByProvisionID, provisionID)
|
|
var i PoolProvision
|
|
err := row.Scan(
|
|
&i.ProvisionID,
|
|
&i.PoolID,
|
|
&i.BillingAccountID,
|
|
&i.SubscriptionID,
|
|
&i.PurchaseID,
|
|
&i.GrantID,
|
|
&i.Quantity,
|
|
&i.Status,
|
|
&i.ActivatedAt,
|
|
&i.SuspendedAt,
|
|
&i.EndedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.ProductID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPoolProvisionBySubscriptionID = `-- name: GetPoolProvisionBySubscriptionID :one
|
|
SELECT provision_id, pool_id, billing_account_id, subscription_id, purchase_id, grant_id, quantity, status, activated_at, suspended_at, ended_at, created_at, updated_at, entitlement_set_id, product_id FROM core.pool_provisions
|
|
WHERE subscription_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPoolProvisionBySubscriptionID(ctx context.Context, subscriptionID uuid.NullUUID) (PoolProvision, error) {
|
|
row := q.db.QueryRowContext(ctx, getPoolProvisionBySubscriptionID, subscriptionID)
|
|
var i PoolProvision
|
|
err := row.Scan(
|
|
&i.ProvisionID,
|
|
&i.PoolID,
|
|
&i.BillingAccountID,
|
|
&i.SubscriptionID,
|
|
&i.PurchaseID,
|
|
&i.GrantID,
|
|
&i.Quantity,
|
|
&i.Status,
|
|
&i.ActivatedAt,
|
|
&i.SuspendedAt,
|
|
&i.EndedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.ProductID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPoolProvisionsByPoolID = `-- name: GetPoolProvisionsByPoolID :many
|
|
|
|
SELECT provision_id, pool_id, billing_account_id, subscription_id, purchase_id, grant_id, quantity, status, activated_at, suspended_at, ended_at, created_at, updated_at, entitlement_set_id, product_id FROM core.pool_provisions
|
|
WHERE pool_id = $1
|
|
ORDER BY created_at ASC
|
|
`
|
|
|
|
// Writes to core.pool_provisions go through the conferral functions
|
|
// (queries/conferral.sql) alone; core_writer holds no direct DML on this
|
|
// table (migration 00005 enclosure). Only read paths live here.
|
|
func (q *Queries) GetPoolProvisionsByPoolID(ctx context.Context, poolID string) ([]PoolProvision, error) {
|
|
rows, err := q.db.QueryContext(ctx, getPoolProvisionsByPoolID, poolID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []PoolProvision{}
|
|
for rows.Next() {
|
|
var i PoolProvision
|
|
if err := rows.Scan(
|
|
&i.ProvisionID,
|
|
&i.PoolID,
|
|
&i.BillingAccountID,
|
|
&i.SubscriptionID,
|
|
&i.PurchaseID,
|
|
&i.GrantID,
|
|
&i.Quantity,
|
|
&i.Status,
|
|
&i.ActivatedAt,
|
|
&i.SuspendedAt,
|
|
&i.EndedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.ProductID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|