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

Rake task for purge_orphans #55

Open
srappel opened this issue Aug 13, 2024 · 0 comments
Open

Rake task for purge_orphans #55

srappel opened this issue Aug 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@srappel
Copy link
Collaborator

srappel commented Aug 13, 2024

There is a defined rake task to purge orphaned sidecars, but when I run it, I get some errors:

    desc "Sidecars - Purge orphans: Destroy orphaned sidecar Active Record objects"
    # When a Sidecar object exists,
    # but it's corresponding SolrDocument is no longer in the Solr index.
    task purge_orphans: [:environment] do
      # Remove all sidecars that have no corresponding SolrDocument
      sidecars = Blacklight::Allmaps::Sidecar.all
      sidecars.each do |sc|
        ::SolrDocument.find(sc.document_id)
      rescue
        sc.destroy
        puts "orphaned / #{sc.document_id} / destroyed"
      end
    end

Expected behavior is that orphaned sidecars would be purged.

Actual behavior is that orphans are not purged with the following error message:

NoMethodError: undefined method `document_id' for #<Blacklight::Allmaps::Sidecar id: 1, solr_document_id: "6cd985a1-1b1f-4d72-be9c-d64e5b3cdb30", document_type: "SolrDocument", manifest_id: nil, annotated: false, allmaps_id: nil, iiif_manifest: nil, allmaps_annotation: nil, solr_version: 1807289517394100224, created_at: "2024-05-15 19:11:52.838121000 +0000", updated_at: "2024-08-13 16:17:50.042777000 +0000"> (NoMethodError)
Did you mean? document_type

@srappel srappel added the bug Something isn't working label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant