mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge pull request #3157 from ripcurlx/change-burned-bsq-to-grouped-by-day
Group burned BSQ by day
This commit is contained in:
commit
d701d2f37a
@ -82,6 +82,7 @@ import java.sql.Date;
|
||||
public class SupplyView extends ActivatableView<GridPane, Void> implements DaoStateListener {
|
||||
|
||||
private static final String MONTH = "month";
|
||||
private static final String DAY = "day";
|
||||
|
||||
private final DaoFacade daoFacade;
|
||||
private DaoStateService daoStateService;
|
||||
@ -113,6 +114,7 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
||||
public void initialize() {
|
||||
|
||||
ADJUSTERS.put(MONTH, TemporalAdjusters.firstDayOfMonth());
|
||||
ADJUSTERS.put(DAY, TemporalAdjusters.ofDateAdjuster(d -> d));
|
||||
|
||||
createSupplyIncreasedInformation();
|
||||
createSupplyReducedInformation();
|
||||
@ -161,7 +163,7 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
||||
|
||||
|
||||
seriesBSQIssued = new XYChart.Series<>();
|
||||
createChart(seriesBSQIssued, Res.get("dao.factsAndFigures.supply.issued"));
|
||||
createChart(seriesBSQIssued, Res.get("dao.factsAndFigures.supply.issued"), "MMM uu");
|
||||
}
|
||||
|
||||
private void createSupplyReducedInformation() {
|
||||
@ -173,7 +175,7 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
||||
Res.get("dao.factsAndFigures.supply.invalidTxs"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
|
||||
|
||||
seriesBSQBurnt = new XYChart.Series<>();
|
||||
createChart(seriesBSQBurnt, Res.get("dao.factsAndFigures.supply.burnt"));
|
||||
createChart(seriesBSQBurnt, Res.get("dao.factsAndFigures.supply.burnt"), "d MMM");
|
||||
}
|
||||
|
||||
private void createSupplyLockedInformation() {
|
||||
@ -193,7 +195,8 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
||||
Res.get("dao.factsAndFigures.supply.totalConfiscatedAmount")).second;
|
||||
}
|
||||
|
||||
private void createChart(XYChart.Series<Number, Number> series, String seriesLabel) {
|
||||
@SuppressWarnings("unchecked")
|
||||
private void createChart(XYChart.Series<Number, Number> series, String seriesLabel, String datePattern) {
|
||||
NumberAxis xAxis = new NumberAxis();
|
||||
xAxis.setForceZeroInRange(false);
|
||||
xAxis.setAutoRanging(true);
|
||||
@ -205,7 +208,7 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
||||
public String toString(Number timestamp) {
|
||||
LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(timestamp.longValue(),
|
||||
0, OffsetDateTime.now(ZoneId.systemDefault()).getOffset());
|
||||
return localDateTime.format(DateTimeFormatter.ofPattern("MMM uu", GlobalSettings.getLocale()));
|
||||
return localDateTime.format(DateTimeFormatter.ofPattern(datePattern, GlobalSettings.getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -296,15 +299,15 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
||||
Set<Tx> burntTxs = new HashSet<>(daoStateService.getBurntFeeTxs());
|
||||
burntTxs.addAll(daoStateService.getInvalidTxs());
|
||||
|
||||
Map<LocalDate, List<Tx>> burntBsqByMonth = burntTxs.stream()
|
||||
Map<LocalDate, List<Tx>> burntBsqByDay = burntTxs.stream()
|
||||
.sorted(Comparator.comparing(Tx::getTime))
|
||||
.collect(Collectors.groupingBy(item -> new Date(item.getTime()).toLocalDate()
|
||||
.with(ADJUSTERS.get(MONTH))));
|
||||
.with(ADJUSTERS.get(DAY))));
|
||||
|
||||
List<XYChart.Data<Number, Number>> updatedBurntBsq = burntBsqByMonth.keySet().stream()
|
||||
List<XYChart.Data<Number, Number>> updatedBurntBsq = burntBsqByDay.keySet().stream()
|
||||
.map(date -> {
|
||||
ZonedDateTime zonedDateTime = date.atStartOfDay(ZoneId.systemDefault());
|
||||
return new XYChart.Data<Number, Number>(zonedDateTime.toInstant().getEpochSecond(), burntBsqByMonth.get(date)
|
||||
return new XYChart.Data<Number, Number>(zonedDateTime.toInstant().getEpochSecond(), burntBsqByDay.get(date)
|
||||
.stream()
|
||||
.mapToDouble(Tx::getBurntBsq)
|
||||
.sum()
|
||||
|
Loading…
Reference in New Issue
Block a user