Skip to content

Conversation

@Manoj-nathwani
Copy link
Contributor

Note: This is only fixing the single file uploader

Problem

  • When uploading or editing url/file uploads we are never setting or updating the last_modified field on the resource

Solution

  • Whenever updating the HiddenFormInputs field, update the last_modified with a ISO timestamp

Important gotchas

  • The field may be slightly out-of-date as we only update the last_modified field whenever there is interaction with this react component. So if a user opens the page, waits 10mins before editing the description of the resource, then the timestamp on save would be 10mins old.
  • The last_modified field is always updated, which means if a user edits a resource and makes no changes and hits save, then the last_modified would be the only field updated. If we want to ignore resource edits where the only change was the last_modified then we would need to add validation to the backend.

Copy link
Member

@tomeksabala tomeksabala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. (!!!) Last modified date is still not set with bulk upload
  2. The last modified date must be only set if resource file is changed. Changing just the metadata should not update it. There's metadata_modified field for that.
  3. We could decide that the last_modified date is equal to file successfully uploaded to giftless. You can't get the date from the form page load.

The last_modified field is always updated, which means if a user edits a resource and makes no changes and hits save, then the last_modified would be the only field updated. If we want to ignore resource edits where the only change was the last_modified then we would need to add validation to the backend.

That's buggy behavior as well but I believe it'll resolve itself after you fix 2 & 3.


hiddenInputs = {
...hiddenInputs,
last_modified: new Date().toISOString().replace('Z', '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the fact you need to remove tz info from the date string is a bug in ckanext-scheming.
Let's leave it for now (as it doesn't work otherwise) but I'll try to submit an issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Manoj-nathwani
Copy link
Contributor Author

Decided to move this into backend before_create and before_update so it's less hacky to support on the frontend

@fulior fulior deleted the ADX-717-add-last-modified-timestamp-to-single-file-uploader branch May 19, 2022 08:20
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.

3 participants