mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Performance improvement for returning energy summaries from DB. Change the way MQTT values are posted. Add a BOM utf-8 char to the BOM csv, yo dawg, bom.
This commit is contained in:
@@ -20,18 +20,20 @@ public class BackupMinutes {
|
||||
CurrentMonitorDao backupDao = new MongoCurrentMonitorDao(MongoConfig.fromDisk(LanternFiles.BACKUP_PATH + "mongo.cfg"));
|
||||
Date now = new Date();
|
||||
for (Account a : dao.getProxy().queryAll(Account.class)) {
|
||||
if (a.getId() == 100)
|
||||
if (a.getId() == 0)
|
||||
continue;
|
||||
DebugTimer t = new DebugTimer("Account " + a.getId());
|
||||
if (NullUtils.isEmpty(a.getTimezone())) {
|
||||
a.setTimezone("America/Chicago");
|
||||
}
|
||||
TimeZone tz = TimeZone.getTimeZone(a.getTimezone());
|
||||
// Date start = DateUtils.addDays(DateUtils.getMidnightBeforeNow(tz), -2, tz);
|
||||
HubPowerMinute minute = dao.getProxy().queryOne(HubPowerMinute.class, new DaoQuery("account_id", a.getId()), DaoSort.sort("minute"));
|
||||
if (minute == null)
|
||||
continue;
|
||||
Date minStart = DateUtils.addDays(DateUtils.getMidnightBeforeNow(tz), -60, tz);
|
||||
Date start = DateUtils.getMidnightBefore(minute.getMinuteAsDate(), tz);
|
||||
if (minStart.after(start))
|
||||
start = minStart;
|
||||
Date end = DateUtils.addDays(start, 1, tz);
|
||||
while (end.before(now)) {
|
||||
DebugTimer t2 = new DebugTimer("Account Id: " + a.getId() + " Query Day " + DateUtils.format("MM/dd/yyyy", tz, start));
|
||||
@@ -48,5 +50,6 @@ public class BackupMinutes {
|
||||
t.stop();
|
||||
}
|
||||
dao.shutdown();
|
||||
backupDao.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public interface CurrentMonitorDao {
|
||||
List<BreakerPower> getBreakerPowerForAccount(int _accountId);
|
||||
BreakerPower getLatestBreakerPower(int _accountId, int _hub, int _port);
|
||||
BreakerGroupEnergy getBreakerGroupEnergy(int _accountId, String _groupId, EnergyBlockViewMode _viewMode, Date _start);
|
||||
byte[] getBreakerGroupEnergyBinary(int _accountId, String _groupId, EnergyBlockViewMode _viewMode, Date _start);
|
||||
void putBreakerGroupEnergy(BreakerGroupEnergy _energy);
|
||||
|
||||
void putHubPowerMinute(HubPowerMinute _power);
|
||||
|
||||
@@ -125,6 +125,11 @@ public class MongoCurrentMonitorDao implements CurrentMonitorDao {
|
||||
return proxy.queryOne(BreakerGroupEnergy.class, new DaoQuery("_id", BreakerGroupEnergy.toId(_accountId, _groupId, _viewMode, _start)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBreakerGroupEnergyBinary(int _accountId, String _groupId, EnergyBlockViewMode _viewMode, Date _start) {
|
||||
return DaoSerializer.toZipBson(proxy.queryForEntity(BreakerGroupEnergy.class, new DaoQuery("_id", BreakerGroupEnergy.toId(_accountId, _groupId, _viewMode, _start))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSummaries(BreakerGroup _rootGroup, Set<Date> _daysToSummarize, TimeZone _tz) {
|
||||
Set<Date> monthsToSummarize = CollectionUtils.transformToSet(_daysToSummarize, _c -> DateUtils.getStartOfMonth(_c, _tz));
|
||||
|
||||
Reference in New Issue
Block a user