sqldb: remove unused GetInvoice query
This commit is contained in:
3 files changed
-109
No files matched your search
@@ -396,86 +396,6 @@ func (q *Queries) FilterInvoicesReverse(ctx context.Context, arg FilterInvoicesR
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const getInvoice = `-- name: GetInvoice :many
|
|
||||||
|
|
||||||
SELECT i.id, i.hash, i.preimage, i.settle_index, i.settled_at, i.memo, i.amount_msat, i.cltv_delta, i.expiry, i.payment_addr, i.payment_request, i.payment_request_hash, i.state, i.amount_paid_msat, i.is_amp, i.is_hodl, i.is_keysend, i.created_at
|
|
||||||
FROM invoices i
|
|
||||||
LEFT JOIN amp_sub_invoices a
|
|
||||||
ON i.id = a.invoice_id
|
|
||||||
AND (
|
|
||||||
a.set_id = $1 OR $1 IS NULL
|
|
||||||
)
|
|
||||||
WHERE (
|
|
||||||
i.id = $2 OR
|
|
||||||
$2 IS NULL
|
|
||||||
) AND (
|
|
||||||
i.hash = $3 OR
|
|
||||||
$3 IS NULL
|
|
||||||
) AND (
|
|
||||||
i.payment_addr = $4 OR
|
|
||||||
$4 IS NULL
|
|
||||||
)
|
|
||||||
GROUP BY i.id
|
|
||||||
LIMIT 2
|
|
||||||
`
|
|
||||||
|
|
||||||
type GetInvoiceParams struct {
|
|
||||||
SetID []byte
|
|
||||||
AddIndex sql.NullInt64
|
|
||||||
Hash []byte
|
|
||||||
PaymentAddr []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method may return more than one invoice if filter using multiple fields
|
|
||||||
// from different invoices. It is the caller's responsibility to ensure that
|
|
||||||
// we bubble up an error in those cases.
|
|
||||||
func (q *Queries) GetInvoice(ctx context.Context, arg GetInvoiceParams) ([]Invoice, error) {
|
|
||||||
rows, err := q.db.QueryContext(ctx, getInvoice,
|
|
||||||
arg.SetID,
|
|
||||||
arg.AddIndex,
|
|
||||||
arg.Hash,
|
|
||||||
arg.PaymentAddr,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []Invoice
|
|
||||||
for rows.Next() {
|
|
||||||
var i Invoice
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Hash,
|
|
||||||
&i.Preimage,
|
|
||||||
&i.SettleIndex,
|
|
||||||
&i.SettledAt,
|
|
||||||
&i.Memo,
|
|
||||||
&i.AmountMsat,
|
|
||||||
&i.CltvDelta,
|
|
||||||
&i.Expiry,
|
|
||||||
&i.PaymentAddr,
|
|
||||||
&i.PaymentRequest,
|
|
||||||
&i.PaymentRequestHash,
|
|
||||||
&i.State,
|
|
||||||
&i.AmountPaidMsat,
|
|
||||||
&i.IsAmp,
|
|
||||||
&i.IsHodl,
|
|
||||||
&i.IsKeysend,
|
|
||||||
&i.CreatedAt,
|
|
||||||
); 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 getInvoiceByAddr = `-- name: GetInvoiceByAddr :one
|
const getInvoiceByAddr = `-- name: GetInvoiceByAddr :one
|
||||||
SELECT i.id, i.hash, i.preimage, i.settle_index, i.settled_at, i.memo, i.amount_msat, i.cltv_delta, i.expiry, i.payment_addr, i.payment_request, i.payment_request_hash, i.state, i.amount_paid_msat, i.is_amp, i.is_hodl, i.is_keysend, i.created_at
|
SELECT i.id, i.hash, i.preimage, i.settle_index, i.settled_at, i.memo, i.amount_msat, i.cltv_delta, i.expiry, i.payment_addr, i.payment_request, i.payment_request_hash, i.state, i.amount_paid_msat, i.is_amp, i.is_hodl, i.is_keysend, i.created_at
|
||||||
FROM invoices i
|
FROM invoices i
|
||||||
|
|||||||
@@ -107,10 +107,6 @@ type Querier interface {
|
|||||||
GetClosedChannelsSCIDs(ctx context.Context, scids [][]byte) ([][]byte, error)
|
GetClosedChannelsSCIDs(ctx context.Context, scids [][]byte) ([][]byte, error)
|
||||||
GetDatabaseVersion(ctx context.Context) (int32, error)
|
GetDatabaseVersion(ctx context.Context) (int32, error)
|
||||||
GetExtraNodeTypes(ctx context.Context, nodeID int64) ([]GraphNodeExtraType, error)
|
GetExtraNodeTypes(ctx context.Context, nodeID int64) ([]GraphNodeExtraType, error)
|
||||||
// This method may return more than one invoice if filter using multiple fields
|
|
||||||
// from different invoices. It is the caller's responsibility to ensure that
|
|
||||||
// we bubble up an error in those cases.
|
|
||||||
GetInvoice(ctx context.Context, arg GetInvoiceParams) ([]Invoice, error)
|
|
||||||
GetInvoiceByAddr(ctx context.Context, paymentAddr []byte) (Invoice, error)
|
GetInvoiceByAddr(ctx context.Context, paymentAddr []byte) (Invoice, error)
|
||||||
GetInvoiceByHash(ctx context.Context, hash []byte) (Invoice, error)
|
GetInvoiceByHash(ctx context.Context, hash []byte) (Invoice, error)
|
||||||
// TODO(ziggie): This query can only return one invoice if the set_id is
|
// TODO(ziggie): This query can only return one invoice if the set_id is
|
||||||
|
|||||||
@@ -29,31 +29,6 @@ SELECT *
|
|||||||
FROM invoice_features
|
FROM invoice_features
|
||||||
WHERE invoice_id = $1;
|
WHERE invoice_id = $1;
|
||||||
|
|
||||||
-- This method may return more than one invoice if filter using multiple fields
|
|
||||||
-- from different invoices. It is the caller's responsibility to ensure that
|
|
||||||
-- we bubble up an error in those cases.
|
|
||||||
|
|
||||||
-- name: GetInvoice :many
|
|
||||||
SELECT i.*
|
|
||||||
FROM invoices i
|
|
||||||
LEFT JOIN amp_sub_invoices a
|
|
||||||
ON i.id = a.invoice_id
|
|
||||||
AND (
|
|
||||||
a.set_id = sqlc.narg('set_id') OR sqlc.narg('set_id') IS NULL
|
|
||||||
)
|
|
||||||
WHERE (
|
|
||||||
i.id = sqlc.narg('add_index') OR
|
|
||||||
sqlc.narg('add_index') IS NULL
|
|
||||||
) AND (
|
|
||||||
i.hash = sqlc.narg('hash') OR
|
|
||||||
sqlc.narg('hash') IS NULL
|
|
||||||
) AND (
|
|
||||||
i.payment_addr = sqlc.narg('payment_addr') OR
|
|
||||||
sqlc.narg('payment_addr') IS NULL
|
|
||||||
)
|
|
||||||
GROUP BY i.id
|
|
||||||
LIMIT 2;
|
|
||||||
|
|
||||||
-- name: GetInvoiceByHash :one
|
-- name: GetInvoiceByHash :one
|
||||||
SELECT i.*
|
SELECT i.*
|
||||||
FROM invoices i
|
FROM invoices i
|
||||||
|
|||||||
Reference in new issue
Block a user