-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix/standardise dataset times #61
base: main
Are you sure you want to change the base?
Conversation
79be690
to
8b3cacb
Compare
8478675
to
7137785
Compare
The CKAN templates need UTC datetimes with no time zone info. The API wants datetimes in the Europe/Zurich time zone, with time zone info. For other cases when package_show is called, we don't want to reformat the datetimes at all: it is called a lot internally when updating resources, etc.
Also remove debug statements.
Handle cases where the dataset/resource dict doesn't have a particular field.
swiss_date was set as an output validator for the 'modified' and 'issued' fields on datasets and resources. Since it was called on output, not on creating/updating datasets, the errors it added were never logged anywhere and didn't actually change anything. Furthermore, it was validating that values were dates, when in fact we save 'modified' and 'issued' values as isoformat datetime strings.
483c5a4
to
39d976e
Compare
This is to make it easier to tell apart which datetimes in the test are custom fields and which are CKAN default fields.
if dt is False: | ||
continue | ||
|
||
dt_zh = dt.replace(tzinfo=ZURICH) |
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.
What if the tzinfo is already Zurich? Do you think it is worthwhile to check first, if the data is set so we do not have to do it each time or is it likely, that we will get those dates often, even after this code has been in place for a while?
continue | ||
|
||
dt_utc = dt.replace(tzinfo=UTC) | ||
dt_zh = dt_utc.astimezone(ZURICH) |
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.
Same as above. I don't think it should hurt us a lot, but as it is more than one parameter we are changing every time, this might be worth checking?
if path.startswith("/api") and not path.startswith("/api/action"): | ||
# The API client for CKAN's JS modules uses a path starting | ||
# /api/action, i.e. without a version number. All other API calls | ||
# should include a version number. |
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.
TIL, I assumed that since a few version it is allowed to leave the version out of an standard API call as well, but just tested it with one of our projects and indeed you have to have the version in there, still.
No description provided.