Skip to content

Commit

Permalink
PP-893: more statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
ubhaller committed Feb 16, 2021
1 parent ec80a3f commit 1fd5540
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,44 +1,78 @@
package org.dpppt.additionalinfo.backend.ws.model.statistics;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import org.dpppt.additionalinfo.backend.ws.json.CustomLocalDateSerializer;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

public class Statistics {

@JsonSerialize(using = CustomLocalDateSerializer.class)
private LocalDate lastUpdated;

private Integer totalActiveUsers;

private List<History> history = new ArrayList<History>();
@JsonSerialize(using = CustomLocalDateSerializer.class)
private LocalDate lastUpdated;

private Integer totalActiveUsers;

private Integer totalCovidcodesEntered;
private Double totalCovidcodesEntered0to2d;
private Integer newInfectionsSevenDayAvg;
private Double newInfectionsSevenDayAvgRelPrevWeek;

private List<History> history = new ArrayList<History>();

public Integer getTotalActiveUsers() {
return totalActiveUsers;
}

public void setTotalActiveUsers(Integer totalActiveUsers) {
this.totalActiveUsers = totalActiveUsers;
}

public Integer getTotalCovidcodesEntered() {
return totalCovidcodesEntered;
}

public void setTotalCovidcodesEntered(Integer totalCovidcodesEntered) {
this.totalCovidcodesEntered = totalCovidcodesEntered;
}

public Double getTotalCovidcodesEntered0to2d() {
return totalCovidcodesEntered0to2d;
}

public void setTotalCovidcodesEntered0to2d(Double totalCovidcodesEntered0to2d) {
this.totalCovidcodesEntered0to2d = totalCovidcodesEntered0to2d;
}

public Integer getNewInfectionsSevenDayAvg() {
return newInfectionsSevenDayAvg;
}

public Integer getTotalActiveUsers() {
return totalActiveUsers;
}
public void setNewInfectionsSevenDayAvg(Integer newInfectionsSevenDayAvg) {
this.newInfectionsSevenDayAvg = newInfectionsSevenDayAvg;
}

public void setTotalActiveUsers(Integer totalActiveUsers) {
this.totalActiveUsers = totalActiveUsers;
}
public Double getNewInfectionsSevenDayAvgRelPrevWeek() {
return newInfectionsSevenDayAvgRelPrevWeek;
}

public List<History> getHistory() {
return history;
}
public void setNewInfectionsSevenDayAvgRelPrevWeek(Double newInfectionsSevenDayAvgRelPrevWeek) {
this.newInfectionsSevenDayAvgRelPrevWeek = newInfectionsSevenDayAvgRelPrevWeek;
}

public void setHistory(List<History> history) {
this.history = history;
}
public List<History> getHistory() {
return history;
}

public LocalDate getLastUpdated() {
return lastUpdated;
}
public void setHistory(List<History> history) {
this.history = history;
}

public void setLastUpdated(LocalDate lastUpdated) {
this.lastUpdated = lastUpdated;
}
public LocalDate getLastUpdated() {
return lastUpdated;
}

public void setLastUpdated(LocalDate lastUpdated) {
this.lastUpdated = lastUpdated;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,23 @@ private void loadPositiveTestCount(Statistics statistics) throws Exception {
}
StatisticHelper.calculateRollingAverage(statistics);

statistics.setTotalCovidcodesEntered(59532); // TODO replace mock data with splunk data
statistics.setTotalCovidcodesEntered0to2d(0.59576); // TODO replace mock data with splunk data

Integer lastSevenDayAverage = null;
Integer prevWeekSevenDayAverage = null;
for (int i = statistics.getHistory().size() - 1; i > 0; i--) {
lastSevenDayAverage = statistics.getHistory().get(i).getNewInfectionsSevenDayAverage();
if (lastSevenDayAverage != null) {
prevWeekSevenDayAverage =
statistics.getHistory().get(i - 7).getNewInfectionsSevenDayAverage();
break;
}
}
statistics.setNewInfectionsSevenDayAvg(lastSevenDayAverage);
statistics.setNewInfectionsSevenDayAvgRelPrevWeek(
(lastSevenDayAverage / (double) prevWeekSevenDayAverage) - 1);

logger.info("Positive test count loaded");
}

Expand Down

0 comments on commit 1fd5540

Please sign in to comment.