Skip to content
Snippets Groups Projects
Commit aa722e07 authored by Reinder Kraaij's avatar Reinder Kraaij :eye:
Browse files

Core And Station are from same UTC moment

parent b5fe306b
No related branches found
No related tags found
2 merge requests!1213Resolve TMSS-2717 "Refactor details summary + ui tweaks",!1212Resolve TMSS-2717 "Refactor details summary + ui tweaks"
...@@ -78,11 +78,16 @@ export async function fetchLSTStationShift(utcTime,station) { ...@@ -78,11 +78,16 @@ export async function fetchLSTStationShift(utcTime,station) {
} }
let lstresponse = await UtilService.getLST(UTCTimeNow, stations) // we get timing also, makes debugging a lot easier. let lstresponse = await UtilService.getLST(UTCTimeNow, stations) // we get timing also, makes debugging a lot easier.
if (!lstresponse) return -1; if (!lstresponse) return -1;
let lststation = lstresponse.data?.LST?.[station];
let UTCAlsoTimeNow = moment.utc(lstresponse.data?.UTC).format(UIConstants.UTC_DATE_TIME_FORMAT);
let lstcore = lstresponse.data?.LST?.[UIConstants.TIMINGSERVER];
let lst = lstresponse.data?.LST?.[station]; const shiftLSTStation = GetLstShiftinSeconds(lststation, UTCAlsoTimeNow)
let UTCAlsoTimeNow = moment.utc(lstresponse.data?.UTC).format(UIConstants.UTC_DATE_TIME_FORMAT); const shiftLSTCore = GetLstShiftinSeconds(lstcore, UTCAlsoTimeNow)
const shift = GetLstShiftinSeconds(lst, UTCAlsoTimeNow)
return shift return { shiftLSTStation, shiftLSTCore }
} }
export async function fetchLSTShift(startTime, setHeaderSettings) { export async function fetchLSTShift(startTime, setHeaderSettings) {
...@@ -91,7 +96,7 @@ export async function fetchLSTShift(startTime, setHeaderSettings) { ...@@ -91,7 +96,7 @@ export async function fetchLSTShift(startTime, setHeaderSettings) {
setHeaderSettings(prevState => ({ setHeaderSettings(prevState => ({
...prevState, ...prevState,
lstShiftInSeconds: shift lstShiftInSeconds: shift.shiftLSTCore
})) }))
} }
......
...@@ -187,11 +187,11 @@ export function groupRenderer({ group }) { ...@@ -187,11 +187,11 @@ export function groupRenderer({ group }) {
<tr><td>UTC</td><td> {group.cursorInfo.utc}</td></tr> <tr><td>UTC</td><td> {group.cursorInfo.utc}</td></tr>
{group.isSingleStation ? ( {group.isSingleStation ? (
<tr> <tr>
<td>LST Station </td> <td>LST {group.cursorInfo.stationName || 'Station' } </td>
<td>{group.cursorInfo.stationlst}</td> <td>{group.cursorInfo.stationLST}</td>
</tr> </tr>
) : null} ) : null}
<tr><td>LST Core </td><td>{group.cursorInfo.corelst}</td></tr> <tr><td>LST Core </td><td>{group.cursorInfo.coreLST}</td></tr>
</tbody> </tbody>
</table> : null} </table> : null}
</div>; </div>;
......
...@@ -200,31 +200,35 @@ export async function getCursorDateTimes(cursorTimeUTC, groupIndex, groupDate, l ...@@ -200,31 +200,35 @@ export async function getCursorDateTimes(cursorTimeUTC, groupIndex, groupDate, l
const cursorTime = moment(cursorTimeUTC) const cursorTime = moment(cursorTimeUTC)
const cursorDateTimeUTC = moment(groupDate).set({ hour: cursorTime.get('hour'), minute: cursorTime.get('minute'), second: cursorTime.get('second') }); const cursorDateTimeUTC = moment(groupDate).set({ hour: cursorTime.get('hour'), minute: cursorTime.get('minute'), second: cursorTime.get('second') });
let utc = cursorDateTimeUTC.format("HH:mm"); let utc = cursorDateTimeUTC.format("HH:mm");
const cursorDateTimeCoreLST = moment(cursorDateTimeUTC).add(lstShiftInSeconds, 'second'); let shifts = await GetStationLst(isSingleStation, cursorDateTimeUTC, stationName);
let corelst = cursorDateTimeCoreLST.format("HH:mm"); let coreLST = shifts.coreLST;
let stationlst = await GetStationLst(isSingleStation, cursorDateTimeUTC, stationName); let stationLST = shifts.stationLST;
let cursordatetimes = { utc, corelst, stationlst } let cursordatetimes = { utc, coreLST, stationLST, stationName:stationName }
setCursorDateTimes(cursordatetimes) setCursorDateTimes(cursordatetimes)
} }
async function GetStationLst(isSingleStation, cursorDateTimeUTC, stationName) { async function GetStationLst(isSingleStation, cursorDateTimeUTC, stationName = UIConstants.TIMINGSERVER) {
if (!isSingleStation) return;
let lststationshiftSeconds = -2; let lststationshiftSeconds = -2;
let shift;
let key = cursorDateTimeUTC.format(UIConstants.CALENDAR_GROUPING_FORMAT) + "_" + stationName; // we cache on a daily base let key = cursorDateTimeUTC.format(UIConstants.CALENDAR_GROUPING_FORMAT) + "_" + stationName; // we cache on a daily base
if (key in timecache) { if (key in timecache) {
if (!timecache[key].isRetrieved) { return "..."; } if (!timecache[key].isRetrieved) { return "..."; }
lststationshiftSeconds = timecache[key].shift; shift = timecache[key].shift;
lststationshiftSeconds = shift.shiftLSTStation;
} }
if (lststationshiftSeconds <= 0) { if (lststationshiftSeconds == -2) {
timecache[key] = { isRetrieved: false }; timecache[key] = { isRetrieved: false };
lststationshiftSeconds = await fetchLSTStationShift(cursorDateTimeUTC, stationName); shift = await fetchLSTStationShift(cursorDateTimeUTC, stationName);
timecache[key] = { isRetrieved: true, shift: lststationshiftSeconds }; timecache[key] = { isRetrieved: true, shift };
} }
lststationshiftSeconds = moment(cursorDateTimeUTC).add(lststationshiftSeconds, 'second'); const stationLST = moment(cursorDateTimeUTC).add(shift.shiftLSTStation, 'second').format("HH:mm");;
const stationlst = lststationshiftSeconds.format("HH:mm"); const coreLST = moment(cursorDateTimeUTC).add(shift.shiftLSTCore, 'second').format("HH:mm");;
return stationlst;
return { stationLST, coreLST };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment