From aa722e077c7a979b0977d4cb533a8b4903c2020f Mon Sep 17 00:00:00 2001 From: Reinder Kraaij <kraaij@astron.nl> Date: Tue, 14 Nov 2023 23:26:33 +0100 Subject: [PATCH] Core And Station are from same UTC moment --- .../routes/Timeline/data/week.view.data.js | 15 ++++++---- .../helpers/timeline.renderer.helper.js | 6 ++-- .../Timeline/helpers/week.view.helper.js | 30 +++++++++++-------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/data/week.view.data.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/data/week.view.data.js index cbfc496aad5..7d4e3957ce5 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/data/week.view.data.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/data/week.view.data.js @@ -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. 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]; - let UTCAlsoTimeNow = moment.utc(lstresponse.data?.UTC).format(UIConstants.UTC_DATE_TIME_FORMAT); - const shift = GetLstShiftinSeconds(lst, UTCAlsoTimeNow) - return shift + const shiftLSTStation = GetLstShiftinSeconds(lststation, UTCAlsoTimeNow) + const shiftLSTCore = GetLstShiftinSeconds(lstcore, UTCAlsoTimeNow) + + return { shiftLSTStation, shiftLSTCore } } export async function fetchLSTShift(startTime, setHeaderSettings) { @@ -91,7 +96,7 @@ export async function fetchLSTShift(startTime, setHeaderSettings) { setHeaderSettings(prevState => ({ ...prevState, - lstShiftInSeconds: shift + lstShiftInSeconds: shift.shiftLSTCore })) } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/timeline.renderer.helper.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/timeline.renderer.helper.js index 89faa599b8c..8e5979d94ee 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/timeline.renderer.helper.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/timeline.renderer.helper.js @@ -187,11 +187,11 @@ export function groupRenderer({ group }) { <tr><td>UTC</td><td> {group.cursorInfo.utc}</td></tr> {group.isSingleStation ? ( <tr> - <td>LST Station </td> - <td>{group.cursorInfo.stationlst}</td> + <td>LST {group.cursorInfo.stationName || 'Station' } </td> + <td>{group.cursorInfo.stationLST}</td> </tr> ) : null} - <tr><td>LST Core </td><td>{group.cursorInfo.corelst}</td></tr> + <tr><td>LST Core </td><td>{group.cursorInfo.coreLST}</td></tr> </tbody> </table> : null} </div>; diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js index 9b609b71138..e1073018cfe 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js @@ -200,31 +200,35 @@ export async function getCursorDateTimes(cursorTimeUTC, groupIndex, groupDate, l const cursorTime = moment(cursorTimeUTC) const cursorDateTimeUTC = moment(groupDate).set({ hour: cursorTime.get('hour'), minute: cursorTime.get('minute'), second: cursorTime.get('second') }); let utc = cursorDateTimeUTC.format("HH:mm"); - const cursorDateTimeCoreLST = moment(cursorDateTimeUTC).add(lstShiftInSeconds, 'second'); - let corelst = cursorDateTimeCoreLST.format("HH:mm"); - let stationlst = await GetStationLst(isSingleStation, cursorDateTimeUTC, stationName); - let cursordatetimes = { utc, corelst, stationlst } + let shifts = await GetStationLst(isSingleStation, cursorDateTimeUTC, stationName); + let coreLST = shifts.coreLST; + let stationLST = shifts.stationLST; + let cursordatetimes = { utc, coreLST, stationLST, stationName:stationName } setCursorDateTimes(cursordatetimes) } -async function GetStationLst(isSingleStation, cursorDateTimeUTC, stationName) { +async function GetStationLst(isSingleStation, cursorDateTimeUTC, stationName = UIConstants.TIMINGSERVER) { - if (!isSingleStation) return; let lststationshiftSeconds = -2; + let shift; let key = cursorDateTimeUTC.format(UIConstants.CALENDAR_GROUPING_FORMAT) + "_" + stationName; // we cache on a daily base if (key in timecache) { 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 }; - lststationshiftSeconds = await fetchLSTStationShift(cursorDateTimeUTC, stationName); - timecache[key] = { isRetrieved: true, shift: lststationshiftSeconds }; + shift = await fetchLSTStationShift(cursorDateTimeUTC, stationName); + timecache[key] = { isRetrieved: true, shift }; } - lststationshiftSeconds = moment(cursorDateTimeUTC).add(lststationshiftSeconds, 'second'); - const stationlst = lststationshiftSeconds.format("HH:mm"); - return stationlst; + const stationLST = moment(cursorDateTimeUTC).add(shift.shiftLSTStation, 'second').format("HH:mm");; + const coreLST = moment(cursorDateTimeUTC).add(shift.shiftLSTCore, 'second').format("HH:mm");; + + + + return { stationLST, coreLST }; } -- GitLab