Skip to content
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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

Conversation

bellisk
Copy link
Collaborator

@bellisk bellisk commented Apr 23, 2024

No description provided.

@bellisk bellisk marked this pull request as ready for review April 25, 2024 13:45
@bellisk bellisk force-pushed the fix/standardise-dataset-times branch from 79be690 to 8b3cacb Compare May 13, 2024 14:06
@bellisk bellisk force-pushed the fix/standardise-dataset-times branch 4 times, most recently from 8478675 to 7137785 Compare May 28, 2024 09:22
bellisk added 24 commits May 28, 2024 16:25
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.
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.
@bellisk bellisk force-pushed the fix/standardise-dataset-times branch from 483c5a4 to 39d976e Compare May 28, 2024 14:29
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)
Copy link
Member

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)
Copy link
Member

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.
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants