-
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
feat: first-pass at handling "download/<label>:: <url>" as an array #45
base: main
Are you sure you want to change the base?
feat: first-pass at handling "download/<label>:: <url>" as an array #45
Conversation
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.
Just reading through, this looks great, thanks! download/
is a good way to handle it. The only changes I'd like to see are removing the commented sections, and then we need to have an idea of the "upgrade" path. Do we just re-save all records? Do we need a one-off script/command to fix this up? Let me know what you think.
Thank you! I've removed the commented-out code blocks - some logging and logic bits that I was experimenting with 👍 For existing data, there are a few cases already present:
We could write a script to do this or I could simply adjust these manually - as mentioned above, the simple key-value approach where the key is So my hope is that this sort of self-migrates over time 👍 |
# downloadUrl is a single string | ||
lines += f"{x}:: {y}\n" | ||
else: | ||
lines += f"{x}:: {y}\n" |
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.
Hm, what if in the except block, we force a transformation to the new pattern? Something like
lines += f"download/Data Download:: {y}"
That way, when a form is opened for an old record, it will auto-populate the old download link into the new format, and then get saved appropriately. We can have students go through all the records then an check the download links, which will fix them.
Does that make sense?
Problem
We would like to track multiple download links in the
references
field - ideally this would let us offer different data formats for downloadOur current field support a single key-value pair for the download URL, but we want to expand this to support a list of URLs + labels for tracking different formats
Fixes #44
Approach
downloadUrl
list format to match new pattern (seesdoh-indices.json
)We now support a list of values under the key
http://schema.org/downloadUrl
Format
Expected format:
download/<label>:: <url>
Each entry matching the above format with a unique label will be converted into a list of url+label pairs
For example,
download/asdf:: 123456
becomes'http://schema.org/downloadUrl': [{'label':'asdf', 'url':'123456'}]
Precedence
This format will take precedence over a single URL - if the user specifies the following conflicting entries:
Only the special syntax will be recognized, and overwritten to use JSON instead:
If no other entries use this special format, then
http://schema.org/downloadUrl
can still be used for normal key-value pairsHow to Test
References
section and enter the following contents:http://schema.org/url
is a classic key-value that gets preserveddownload/<label>
special syntax entries were transformed into a JSON array of objectshttp://schema.org/downloadUrl
was ignored, because the special syntax entries overwrote it