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

[Feature] Generate release_date property in Indexer #6

Closed
HebaruSan opened this issue Jul 13, 2019 · 1 comment
Closed

[Feature] Generate release_date property in Indexer #6

HebaruSan opened this issue Jul 13, 2019 · 1 comment
Labels
Enhancement New feature or request

Comments

@HebaruSan
Copy link
Member

HebaruSan commented Jul 13, 2019

This is an outgrowth of KSP-CKAN/CKAN#2789 (comment). I assume that the initial functionality of the queue-based bot will be identical to NetKAN-bot, so ideas for further improvements should be submitted here for better tracking.

Motivation

KSP-CKAN/CKAN#1155 requests a release date column in CKAN. Currently we do not have the ability to generate the metadata to populate such a column. It should correspond roughly to when a given version was indexed. netkan.exe can't generate this value by itself, because it requires knowing when the bot originally found a version, which can't be determined from checking the .netkan file or the .zip download. Some interaction with the CKAN-meta repo over time is necessary.

Suggestion

The Indexer component could add and/or update this property between receipt of inflated metadata and saving it to disk. Sample code here:

https://gist.github.com/HebaruSan/665599c5c8fb9733c23c8aa64f29bc48

  • If the file exists, pull the release_date property forward unchanged
  • If the file exists but has no release_date property, set it to the file creation date in git
  • If the file is brand new, set the release_date property to now

Code notes

  • object_pairs_hook=collections.OrderedDict preserves the ordering of the properties
  • .isoformat(timespec='seconds') formats the datetime according to ISO8601, the format most commonly used by internet programmers and widely supported by languages and runtimes
  • git log --format='%aI' -- filename prints the dates of all commits for a file in reverse chronological order, so the oldest is at the end of the list

Note that the git log command will only work with a full (non-shallow) clone of the repo, otherwise the full history of the file won't be present.

@HebaruSan
Copy link
Member Author

HebaruSan commented Jun 6, 2020

Replaced by KSP-CKAN/CKAN#2916.

EDIT: Oops, this was the issue, not the pull request.

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

Successfully merging a pull request may close this issue.

1 participant