-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let's Control Time #1317
Merged
Merged
Let's Control Time #1317
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
greg-does-weather
approved these changes
Jun 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not sure this will be at all useful
Co-authored-by: Greg Walker <[email protected]>
eric-gade
force-pushed
the
eg-lets-control-time
branch
from
June 28, 2024 13:35
16b2d07
to
38cbb76
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do? 🛠️
This PR implements a way for us to control time (but not space -- being lords of all creation will have to wait for a subsequent PR).
The gist is that setting the
WX_NOW_TIMESTAMP
to a valid ISO timestamp will set the "now" time to be that value in both the drupal and api-proxy containers. The upshot being that, in certain cases, we can control what "now" means in development environments.Additionally, we provide in-code / rest methods for updating the now value, should such a need arise.
What does the reviewer need to know? 🤔
Drupal Side
The Drupal dev settings file will now check for an env variable
WX_NOW_TIMESTAMP
and, if set, will set the$settings['wx_now_timestamp']
key to that value.The
DateTimeUtility
has a static method fornow()
that will check the Drupal settings. If there is a timestamp there, it will create a DateTime object according to that timestamp. If not, it will check to see if the setter has been used to programmatically set a system-widenow
timestamp, and use that. Otherwise, it uses the actual current time as "now".One issue to note: Every time you run
make cc
or anything that reloads the Drupal app, you will need to re-pass the environment variable. This is because the settings file is re-read in these cases, and if it doesn't see the environment variable, it will simply use the current time as the "now" value.API Proxy Side
The API proxy application has similarly been updated, so the
config
object has getters and setters for itsnow
property. The getter will:WX_NOW_TIMESTAMP
and, if present, parse adayjs
object from it, otherwiseYou can progammatically set the time by sending a get request like so:
Additionally, the method and current "now" time will be displayed in the proxy's main index UI.