Merge pull request #6741 from jmacxx/add_bsq_burned_to_report

Add BSQ burned column in monthly burningman status report.
This commit is contained in:
Alejandro García 2023-06-30 17:59:35 +00:00 committed by GitHub
commit 60e48d92a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -45,12 +45,14 @@ import javax.inject.Singleton;
import com.google.common.annotations.VisibleForTesting;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.LongStream;
import lombok.extern.slf4j.Slf4j;
@ -359,6 +361,17 @@ public class BurningManPresentationService implements DaoStateListener {
.sum();
}
public long getBsqBurnedByMonth(Date dateFilter) {
Set<BurnOutputModel> defaultZeroBurn = new HashSet<>();
defaultZeroBurn.add(new BurnOutputModel(0, 0, 0, "", 0L, 0));
Map<String, BurningManCandidate> burningMen = getBurningManCandidatesByName();
return burningMen.values().stream()
.map(burningMan -> burningMan.getBurnOutputModelsByMonth().getOrDefault(dateFilter, defaultZeroBurn).stream()
.mapToLong(BurnOutputModel::getAmount))
.mapToLong(LongStream::sum)
.sum();
}
public String getGenesisTxId() {
return daoStateService.getGenesisTxId();
}

View File

@ -675,7 +675,7 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
private void exportToCSV() {
List<String> result = new ArrayList<>();
String separator = "~";
String tableColumns = "Month~BTC Fees~Fees as BSQ~DPT as BTC~DPT as BSQ~Distributed BTC~Distributed BTC as BSQ";
String tableColumns = "Month~BTC Fees~Fees as BSQ~DPT as BTC~DPT as BSQ~Distributed BTC~Distributed BTC as BSQ~BSQ burned";
CSVEntryConverter<String> headerConverter = item -> tableColumns.split(separator);
CSVEntryConverter<String> contentConverter = item -> item.split(separator);
Date now = new Date();
@ -686,6 +686,7 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
long feeAsBsqSum = 0;
long dptAsBsqSum = 0;
long distributedBtcAsBsqSum = 0;
long bsqBurnedSum = 0;
long feeAsBsq, dptAsBsq, distributedBtcAsBsq;
int year = 2023;
int month = 0;
@ -697,7 +698,7 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
Map<Date, Price> averageBsqPriceByMonth = burningManAccountingService.getAverageBsqPriceByMonth();
Optional<Price> price = Optional.ofNullable(averageBsqPriceByMonth.get(date));
long bsqBurned = burningManPresentationService.getBsqBurnedByMonth(date);
List<ReceivedBtcBalanceEntry> distributedBtcBalanceByMonth = burningManAccountingService.getDistributedBtcBalanceByMonth(date)
.collect(Collectors.toList());
long feeAsBtc = distributedBtcBalanceByMonth.stream()
@ -726,7 +727,7 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
feeAsBsqSum += feeAsBsq;
dptAsBsqSum += dptAsBsq;
distributedBtcAsBsqSum += distributedBtcAsBsq;
bsqBurnedSum += bsqBurned;
line = new SimpleDateFormat("MMM yyyy", Locale.ENGLISH).format(date)
+ separator + btcFormatter.formatCoin(Coin.valueOf(feeAsBtc))
@ -734,7 +735,8 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
+ separator + btcFormatter.formatCoin(Coin.valueOf(dptAsBtc))
+ separator + bsqFormatter.formatCoin(Coin.valueOf(dptAsBsq))
+ separator + btcFormatter.formatCoin(Coin.valueOf(distributedBtc))
+ separator + bsqFormatter.formatCoin(Coin.valueOf(distributedBtcAsBsq));
+ separator + bsqFormatter.formatCoin(Coin.valueOf(distributedBtcAsBsq))
+ separator + bsqFormatter.formatCoin(Coin.valueOf(bsqBurned));
result.add(line);
if (++month > 11) {
month = 0;
@ -750,7 +752,8 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
+ separator + btcFormatter.formatCoin(Coin.valueOf(dptAsBtcSum))
+ separator + bsqFormatter.formatCoin(Coin.valueOf(dptAsBsqSum))
+ separator + btcFormatter.formatCoin(Coin.valueOf(distributedBtcSum))
+ separator + bsqFormatter.formatCoin(Coin.valueOf(distributedBtcAsBsqSum));
+ separator + bsqFormatter.formatCoin(Coin.valueOf(distributedBtcAsBsqSum))
+ separator + bsqFormatter.formatCoin(Coin.valueOf(bsqBurnedSum));
result.add(line);
GUIUtil.exportCSV("Burningman_dao_revenue.csv", headerConverter, contentConverter,