refresh-data - make guard condition better readable

This commit is contained in:
AdrianLxM 2017-07-28 05:48:34 +02:00
parent f680d70548
commit 785e1b323c

View file

@ -323,9 +323,10 @@ public class ComboPlugin implements PluginBase, PumpInterface {
return; return;
} }
if (!reason.toLowerCase().contains("user") boolean notAUserRequest = !reason.toLowerCase().contains("user");
&& lastCmdTime.getTime() > 0 boolean wasRunAtLeastOnce = lastCmdTime.getTime() > 0;
&& System.currentTimeMillis() < lastCmdTime.getTime() + 60 * 1000) { boolean ranWithinTheLastMinute = System.currentTimeMillis() < lastCmdTime.getTime() + 60 * 1000;
if (notAUserRequest && wasRunAtLeastOnce && ranWithinTheLastMinute) {
log.debug("Not fetching state from pump, since we did already within the last 60 seconds"); log.debug("Not fetching state from pump, since we did already within the last 60 seconds");
} else { } else {
runCommand(new ReadPumpStateCommand()); runCommand(new ReadPumpStateCommand());