Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ryan's brain dump for the problem
First you got a function in the
src/plugins/home/server/services/sample_data/routes/install.ts
to update the log timestamp to current timeIn the Current Logic:
The function
src/plugins/home/server/services/sample_data/lib/translate_timestamp.ts
calculates the difference betweensource
andsourceReference
, and then applies that difference totargetReference
:If
sourceReference
andsource
are not on the same date, the time difference between them gets added when translating to thetargetReference
, potentially introducing an unintended shift. Since thesource
in the log is 2024-10-16 (you can console log it), and thesourceReference
in code you setup is 2024-10-15 so that, in your case, the time delta is 1 day. These two days will be added into thetargetReference
, for the query we tried so that it is thenow
for your machine's local time. The return of the function will benow
+time delta
, which will be 1 days in the future. Thats explained why when I installed it at midnight of OCT 17 it shows OCT 18 in index timestamp.Solution: Set
sourceReference
to the Same Date assource
If our goal is to maintain the same date for
source
during the translation, then settingsourceReference
to the same date as source would prevent any additional time from being added. Thats why I made this commit, so that thecurrentTimeMarker
as thesourceReference
matches what you got in the log. - You can try out by console log every single line intranslateTimeRelativeToDifference()
with/without my change.