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

Use ReferenceLookup to determine if a resource is in use #4093

Merged
merged 10 commits into from Jan 29, 2024

Conversation

jastraat
Copy link
Contributor

@jastraat jastraat commented Jan 16, 2024

This PR modifies the MetastoreSubscriber to check for in use resources during orphan reference processing using the same approach (referenceLookup) that was already used by ResourcePurger.

  • Test coverage exists
  • Documentation exists

QA Steps

  • --- Prep ---
  • Create a vanilla DKAN site.
  • Check the resource settings. ( admin/dkan/resources ) Purge tables and purge files should both checked and delete local resource should be unchecked. Set "Resource download url display" to Local URL and save.
  • Enable last modified as the only triggering property ( admin/dkan/datastore )
  • Set the default moderation state to draft. ( admin/config/workflow/workflows/manage/dkan_publishing )
  • Add a new dataset ( node/add/data ) with a distribution of http://demo.getdkan.org/sites/default/files/distribution/cedcd327-4e5d-43f9-8eb1-c11850fa7c55/Bike_Lane.csv Make sure to set file format to CSV. Save as a draft.
  • Run cron twice (localizer + importer)
  • Publish the dataset using the admin dataset table ( admin/dkan/datasets )
  • ddev drush queue:list - resource_purger queue
  • Run cron
  • Confirm that the dataset displays correctly at dataset/[dataset_id]
  • --- Test an edit that DOES NOT require a datastore import ---
  • Update the title of the dataset distribution (File Title) save the dataset as a draft (Note: there is a separate bug in DKAN if the dataset is saved as published with a change to distribution that would create a new distribution and "draft" is the default moderation state.)
  • ddev drush queue:list - should not have any datastore_import queue items
  • Confirm that there is a new draft distribution with the updated title ( admin/dkan/datasets?title=&data-type=distribution&status=All&moderation_state=All )
  • Publish the latest revision of the dataset using the admin dataset table ( admin/dkan/datasets )
  • Run cron
  • Confirm that that the new distribution with the updated title was published and the old distribution orphaned ( admin/dkan/datasets?title=&data-type=distribution&status=All&moderation_state=All )
  • Confirm that the datastore table still exists along with the file resource and that the dataset displays correctly at dataset/[dataset_id]
  • --- Test an edit that DOES require a datastore import ---
  • Update the CSV of the dataset distribution to https://demo.getdkan.org/sites/default/files/distribution/95f8eac4-fd1f-4b35-8472-5c87e9425dfa/Asthma-Prevalence-Map-2017.csv Save the dataset as a draft
  • Confirm that there is a new draft distribution with the updated CSV ( admin/dkan/datasets?title=&data-type=distribution&status=All&moderation_state=All )
  • ddev drush queue:list - should have a localizer queue
  • Run cron
  • ddev drush queue:list - should have datastore import
  • Run cron
  • Publish the latest revision of the dataset using the admin dataset table ( admin/dkan/datasets )
  • drush queue:list - should have orphan_reference_processor and resource_purger
  • Run cron
  • Confirm that that the new distribution with the updated CSV was published and the old distribution orphaned ( admin/dkan/datasets?title=&data-type=distribution&status=All&moderation_state=All )
  • Confirm that the old distribution table and file resource were removed.

Copy link
Member

@dafeder dafeder left a comment

Choose a reason for hiding this comment

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

Found another issue - on the edit step, if cron is not run between save new revision and publish new revision, but run once after both, the datastore is dropped. If cron is run both times, it is not.

@jastraat jastraat requested a review from dafeder January 24, 2024 18:13
@paul-m paul-m self-assigned this Jan 29, 2024
Copy link
Contributor

@paul-m paul-m left a comment

Choose a reason for hiding this comment

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

Made it through all the testing steps with success.

@dafeder dafeder merged commit 30d823e into 2.x Jan 29, 2024
12 checks passed
@dafeder dafeder deleted the WCMS-18067-orphan_local_url branch January 29, 2024 23:26
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

3 participants