Skip to content

Commit

Permalink
(2797) Questionable values always included in export
Browse files Browse the repository at this point in the history
  • Loading branch information
squaregoldfish committed Dec 5, 2023
1 parent 3ad4a53 commit 085f344
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions WebApp/src/uk/ac/exeter/QuinCe/data/Export/ExportOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ public class ExportOption {
private boolean measurementsOnly = false;

/**
* Only export good measurements and/or sensor values.
* Do not export Bad measurements and/or sensor values.
*
* <p>
* If a bad sensor value is used by a good measurement, it will still be
* included.
* </p>
*/
private boolean goodOnly = false;
private boolean skipBad = false;

/**
* Indicates whether export option should be visible in webapp
Expand Down Expand Up @@ -228,8 +228,8 @@ protected void setMeasurementsOnly(boolean measurementsOnly) {
this.measurementsOnly = measurementsOnly;
}

protected void setGoodOnly(boolean goodOnly) {
this.goodOnly = goodOnly;
protected void setSkipBad(boolean skipBad) {
this.skipBad = skipBad;
}

protected void setDataClass(Class<? extends ExportData> dataClass) {
Expand Down Expand Up @@ -308,12 +308,12 @@ public boolean measurementsOnly() {
return measurementsOnly;
}

public boolean goodOnly() {
return goodOnly;
public boolean skipBad() {
return skipBad;
}

public boolean filterSensorValues() {
return measurementsOnly || goodOnly;
return measurementsOnly || skipBad;
}

public boolean getVisible() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public ExportOption deserialize(JsonElement json, Type typeOfT,
.setMeasurementsOnly(jsonObj.get("measurementsOnly").getAsBoolean());
}

if (jsonObj.has("goodOnly")) {
option.setGoodOnly(jsonObj.get("goodOnly").getAsBoolean());
if (jsonObj.has("skipBad")) {
option.setSkipBad(jsonObj.get("skipBad").getAsBoolean());
}

if (jsonObj.has("exportDataClass")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ public void loadDataAction() throws Exception {
/*
* Filter measurements to only contain those with Good QC flags if required
*/
if (exportOption.goodOnly()) {
if (exportOption.skipBad()) {
TreeMap<LocalDateTime, Measurement> filteredMeasurements = new TreeMap<LocalDateTime, Measurement>();

for (Map.Entry<LocalDateTime, Measurement> entry : measurements
.entrySet()) {
if (entry.getValue().getQCFlag().isGood()) {
if (!entry.getValue().getQCFlag().equals(Flag.BAD)) {
filteredMeasurements.put(entry.getKey(), entry.getValue());
}
}
Expand Down Expand Up @@ -137,9 +137,9 @@ public void loadDataAction() throws Exception {
* If we don't want values from only Measurements, but we do want only
* Good values, filter them here.
*/
if (!exportOption.measurementsOnly() && exportOption.goodOnly()) {
if (!exportOption.measurementsOnly() && exportOption.skipBad()) {
List<Long> goodIds = sensorValues.getAll().stream()
.filter(v -> v.getUserQCFlag().isGood()).map(v -> v.getId()).toList();
.filter(v -> !v.getUserQCFlag().equals(Flag.BAD)).map(v -> v.getId()).toList();

filteredIds.addAll(goodIds);
}
Expand Down
2 changes: 1 addition & 1 deletion configuration/export_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"includeCalculationColumns": true,
"includeUnits": false,
"measurementsOnly": true,
"goodOnly": true,
"skipBad": true,
"timestampHeader": "date time",
"timestampFormat": "uuuu-MM-dd HH:mm:ss",
"replaceColumnHeaders": {
Expand Down

0 comments on commit 085f344

Please sign in to comment.