From 92a2bb4d320a069c19caebdfdf59bc75047e6367 Mon Sep 17 00:00:00 2001 From: Kukks Date: Wed, 2 Jan 2019 12:04:35 +0100 Subject: [PATCH] fixes to computed goal result --- BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs | 12 ++++++------ .../Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml | 13 +++++++------ BTCPayServer/wwwroot/crowdfund/app.js | 4 +++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs b/BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs index b7a5aaeeb..f9eb5ccf8 100644 --- a/BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs +++ b/BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs @@ -131,12 +131,12 @@ namespace BTCPayServer.Hubs RateFetcher rateFetcher, RateRules rateRules) { decimal result = 0; - - var groupingByCurrency = invoices.GroupBy(entity => entity.ProductInformation.Currency); + + var stats = GetCurrentContributionAmountStats(invoices); var ratesTask = rateFetcher.FetchRates( - groupingByCurrency - .Select((entities) => new CurrencyPair(entities.Key, primaryCurrency)) + stats.Keys + .Select((x) => new CurrencyPair(PaymentMethodId.Parse(x).CryptoCode, primaryCurrency)) .ToHashSet(), rateRules); @@ -148,8 +148,8 @@ namespace BTCPayServer.Hubs var tResult = await rateTask.Value; var rate = tResult.BidAsk?.Bid; if (rate == null) return; - var currencyGroup = groupingByCurrency.Single(entities => entities.Key == rateTask.Key.Left); - result += currencyGroup.Sum(entity => entity.ProductInformation.Price / rate.Value); + var currencyGroup = stats[rateTask.Key.Left]; + result += currencyGroup / rate.Value; })); } diff --git a/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml b/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml index 11302b061..b90697401 100644 --- a/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml +++ b/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml @@ -93,7 +93,7 @@ -