Skip to content

Commit

Permalink
[Minor] Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eitch committed Oct 21, 2024
1 parent f119a89 commit 0687761
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ public int getLastDay() {

private synchronized int getInTimeFrame(long amount, ChronoUnit unit) {
LocalDateTime now = LocalDateTime.now();
return (int) this.events
.stream()
.filter(tx -> SECONDS.between(tx.timestamp, now) < unit.getDuration().getSeconds() * amount)
.count();
long amountSeconds = unit.getDuration().getSeconds() * amount;
return (int) this.events.stream().filter(tx -> SECONDS.between(tx.timestamp, now) < amountSeconds).count();
}

public synchronized JsonObject toJson() {
Expand Down Expand Up @@ -85,9 +83,8 @@ public synchronized JsonObject toJson() {
}

private Duration getMedian(List<Duration> durations) {
if (durations.isEmpty()) {
if (durations.isEmpty())
return Duration.ZERO;
}
List<Duration> sorted = durations.stream().sorted().toList();
int middle = sorted.size() / 2;
if (sorted.size() % 2 == 0) {
Expand Down

0 comments on commit 0687761

Please sign in to comment.