Skip to content

Commit 85a0f4a

Browse files
committed
Keep track of last-uploaded timestamp only when actually uploading.
1 parent f3c53f5 commit 85a0f4a

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

sensor-data-bridge/src/main/java/nl/bertriksikken/senscom/SensComWorker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ private void performUpload(AppDeviceId appDeviceId) {
105105

106106
// drop stale data
107107
Duration age = Duration.between(data.getCreationTime(), Instant.now());
108-
LOG.info("Sensor data age {} before upload for {}", age, appDeviceId);
109108
if (age.toSeconds() > 3600) {
110109
LOG.warn("Dropped stale data for {}: {}", appDeviceId, data);
111110
return;
@@ -122,7 +121,6 @@ private void performUpload(AppDeviceId appDeviceId) {
122121
return;
123122
}
124123
}
125-
lastUploadTimes.put(sensorId, now);
126124

127125
// pin 1 (dust sensors)
128126
if (data.hasValue(ESensorItem.PM10) || data.hasValue(ESensorItem.PM2_5) || data.hasValue(ESensorItem.PM1_0)
@@ -228,6 +226,7 @@ private void uploadMeasurement(AppDeviceId appDeviceId, String sensorId, ESensCo
228226
try {
229227
LOG.info("Uploading for {} (id {}, pin {}): '{}'", appDeviceId, sensorId, pin, mapper.writeValueAsString(message));
230228
Instant startTime = Instant.now();
229+
lastUploadTimes.put(sensorId, startTime);
231230
Response<String> response = restClient.pushSensorData(pin.getPin(), sensorId, message).execute();
232231
long millis = Duration.between(startTime, Instant.now()).toMillis();
233232
if (response.isSuccessful()) {

0 commit comments

Comments
 (0)