mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Forgot that I still had everything hard-coded to central time. Changed it to be configurable per account.
This commit is contained in:
@@ -5,6 +5,7 @@ import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.lanternsoftware.currentmonitor.context.Globals;
|
||||
import com.lanternsoftware.util.DateUtils;
|
||||
import com.lanternsoftware.util.LanternFiles;
|
||||
import com.lanternsoftware.util.NullUtils;
|
||||
import com.lanternsoftware.util.ResourceLoader;
|
||||
@@ -38,7 +39,7 @@ public class AuthServlet extends CMServlet {
|
||||
if (idToken != null) {
|
||||
GoogleIdToken.Payload payload = idToken.getPayload();
|
||||
String email = payload.getEmail();
|
||||
authCode = Globals.dao.getAuthCodeForEmail(email);
|
||||
authCode = Globals.dao.getAuthCodeForEmail(email, DateUtils.fromTimeZoneId(_req.getHeader("timezone")));
|
||||
}
|
||||
}
|
||||
catch (Exception _e) {
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.lanternsoftware.currentmonitor.servlet;
|
||||
import com.lanternsoftware.currentmonitor.context.Globals;
|
||||
import com.lanternsoftware.datamodel.currentmonitor.Account;
|
||||
import com.lanternsoftware.datamodel.currentmonitor.SignupResponse;
|
||||
import com.lanternsoftware.util.DateUtils;
|
||||
import com.lanternsoftware.util.NullUtils;
|
||||
import com.lanternsoftware.util.dao.DaoEntity;
|
||||
import com.lanternsoftware.util.dao.DaoSerializer;
|
||||
import com.lanternsoftware.util.email.EmailValidator;
|
||||
import com.lanternsoftware.util.servlet.BasicAuth;
|
||||
|
||||
@@ -38,6 +37,7 @@ public class SignupServlet extends CMServlet {
|
||||
acct = new Account();
|
||||
acct.setUsername(auth.getUsername());
|
||||
acct.setPassword(auth.getPassword());
|
||||
acct.setTimezone(DateUtils.fromTimeZoneId(_req.getHeader("timezone")).getID());
|
||||
Globals.dao.putAccount(acct);
|
||||
String authCode = Globals.dao.authenticateAccount(auth.getUsername(), auth.getPassword());
|
||||
jsonResponse(_rep, SignupResponse.success(authCode));
|
||||
|
||||
@@ -26,7 +26,7 @@ public class RebuildSummaries {
|
||||
public static void main(String[] args) {
|
||||
int accountId = 1;
|
||||
CurrentMonitorDao dao = new MongoCurrentMonitorDao(MongoConfig.fromDisk(LanternFiles.OPS_PATH + "mongo.cfg"));
|
||||
TimeZone tz = TimeZone.getTimeZone("America/Chicago");
|
||||
TimeZone tz = dao.getTimeZoneForAccount(accountId);
|
||||
Date start = DateUtils.date(1, 7, 2021, tz);
|
||||
// Date start = DateUtils.getMidnightBeforeNow(tz);
|
||||
Date end = DateUtils.getMidnightAfterNow(tz);
|
||||
@@ -49,7 +49,7 @@ public class RebuildSummaries {
|
||||
if (energy == null)
|
||||
energy = new BreakerGroupEnergy(root, minute, EnergyBlockViewMode.DAY, day.getKey(), tz);
|
||||
else
|
||||
energy.addEnergy(breakers, breakerKeyToGroup, minute, tz);
|
||||
energy.addEnergy(breakers, breakerKeyToGroup, minute);
|
||||
}
|
||||
timer.stop();
|
||||
if (energy != null)
|
||||
|
||||
Reference in New Issue
Block a user