write new func for finding payments

This commit is contained in:
kiwiidb
2023-11-07 16:01:55 +09:00
parent 8477a22f04
commit 1b067a751f
2 changed files with 18 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"sync"
"time"
"github.com/getAlby/lndhub.go/db/models"
"github.com/getsentry/sentry-go"
@@ -14,6 +15,18 @@ import (
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
)
func (svc *LndhubService) GetPendingPaymentsUntil(ctx context.Context, ts time.Time) ([]models.Invoice, error) {
payments := []models.Invoice{}
err := svc.DB.NewSelect().
Model(&payments).
Where("state = 'initialized'").
Where("type = 'outgoing'").
Where("r_hash != ''").
Where("created_at >= (now() - interval '2 weeks') ").
Scan(ctx)
return payments, err
}
func (svc *LndhubService) GetAllPendingPayments(ctx context.Context) ([]models.Invoice, error) {
payments := []models.Invoice{}
err := svc.DB.NewSelect().Model(&payments).Where("state = 'initialized'").Where("type = 'outgoing'").Where("r_hash != ''").Where("created_at >= (now() - interval '2 weeks') ").Scan(ctx)