mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Do not retrieve all payouts in GetPullPayment every time
This commit is contained in:
parent
cd9feccf6e
commit
371acc84a8
@ -132,7 +132,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
StoreId = storeId,
|
||||
PaymentMethodIds = paymentMethods
|
||||
});
|
||||
var pp = await _pullPaymentService.GetPullPayment(ppId);
|
||||
var pp = await _pullPaymentService.GetPullPayment(ppId, false);
|
||||
return this.Ok(CreatePullPaymentData(pp));
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
{
|
||||
if (pullPaymentId is null)
|
||||
return PullPaymentNotFound();
|
||||
var pp = await _pullPaymentService.GetPullPayment(pullPaymentId);
|
||||
var pp = await _pullPaymentService.GetPullPayment(pullPaymentId, false);
|
||||
if (pp is null)
|
||||
return PullPaymentNotFound();
|
||||
return Ok(CreatePullPaymentData(pp));
|
||||
@ -177,7 +177,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
{
|
||||
if (pullPaymentId is null)
|
||||
return PullPaymentNotFound();
|
||||
var pp = await _pullPaymentService.GetPullPayment(pullPaymentId);
|
||||
var pp = await _pullPaymentService.GetPullPayment(pullPaymentId, true);
|
||||
if (pp is null)
|
||||
return PullPaymentNotFound();
|
||||
var payouts = pp.Payouts .Where(p => p.State != PayoutState.Cancelled || includeCancelled).ToList();
|
||||
@ -193,7 +193,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
if (payoutId is null)
|
||||
return PayoutNotFound();
|
||||
await using var ctx = _dbContextFactory.CreateContext();
|
||||
var pp = await _pullPaymentService.GetPullPayment(pullPaymentId);
|
||||
var pp = await _pullPaymentService.GetPullPayment(pullPaymentId, true);
|
||||
if (pp is null)
|
||||
return PullPaymentNotFound();
|
||||
var payout = pp.Payouts.FirstOrDefault(p => p.Id == payoutId);
|
||||
|
@ -121,10 +121,14 @@ namespace BTCPayServer.HostedServices
|
||||
return o.Id;
|
||||
}
|
||||
|
||||
public async Task<Data.PullPaymentData> GetPullPayment(string pullPaymentId)
|
||||
public async Task<Data.PullPaymentData> GetPullPayment(string pullPaymentId, bool includePayouts)
|
||||
{
|
||||
await using var ctx = _dbContextFactory.CreateContext();
|
||||
return await ctx.PullPayments.Include(data => data.Payouts).FirstOrDefaultAsync(data => data.Id == pullPaymentId);
|
||||
IQueryable<Data.PullPaymentData> query = ctx.PullPayments;
|
||||
if (includePayouts)
|
||||
query = query.Include(data => data.Payouts);
|
||||
|
||||
return await query.FirstOrDefaultAsync(data => data.Id == pullPaymentId);
|
||||
}
|
||||
|
||||
class PayoutRequest
|
||||
@ -205,14 +209,14 @@ namespace BTCPayServer.HostedServices
|
||||
if (o is CancelRequest cancel)
|
||||
{
|
||||
await HandleCancel(cancel);
|
||||
}
|
||||
}
|
||||
if (o is InternalPayoutPaidRequest paid)
|
||||
{
|
||||
await HandleMarkPaid(paid);
|
||||
}
|
||||
}
|
||||
foreach (IPayoutHandler payoutHandler in _payoutHandlers)
|
||||
{
|
||||
await payoutHandler.BackgroundCheck(o);
|
||||
await payoutHandler.BackgroundCheck(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -502,7 +506,7 @@ namespace BTCPayServer.HostedServices
|
||||
public TaskCompletionSource<PayoutPaidRequest.PayoutPaidResult> Completion { get; set; }
|
||||
public PayoutPaidRequest Request { get; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class PayoutPaidRequest
|
||||
@ -515,7 +519,7 @@ namespace BTCPayServer.HostedServices
|
||||
}
|
||||
public string PayoutId { get; set; }
|
||||
public ManualPayoutProof Proof { get; set; }
|
||||
|
||||
|
||||
public static string GetErrorMessage(PayoutPaidResult result)
|
||||
{
|
||||
switch (result)
|
||||
@ -530,7 +534,7 @@ namespace BTCPayServer.HostedServices
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ClaimRequest
|
||||
|
Loading…
Reference in New Issue
Block a user