app/models/page.rb
# Occasionally you'll see "NO NAME" for some page IDs (in searches, associations, collections, and so on), and this
# can be caused by the native_node_id being set to a node that no longer exists. You should try and track down the
# source of that problem, but this code can be used to (slowly) fix the problem, where it's possible to do so:
Occasionally you'll see "NO NAME" for some page IDs (in searches, associations, collections, and so on), and this
can be caused by the native_node_id being set to a node that no longer exists. You should try and track down the
source of that problem, but this code can be used to (slowly) fix the problem, where it's possible to do so.
Occasionally you ' ll see " NO NAME " for some page IDs ( in searches associations collections and so on ) and this can be caused by the native_node_id being set to a node that no longer exists . You should try and track down the source of that problem but this code can be used to ( slowly ) fix the problem where it ' s possible to do so .
def remove_if_nodeless
      Page.find_in_batches(batch_size: 10_000) do |group|
        group_ids = group.map(&:id)
        have_ids = Node.where(page_id: group_ids).pluck(:page_id)
        bad_pages = group_ids - have_ids
        next if bad_pages.empty?
        [PageIcon, ScientificName, SearchSuggestion, Vernacular, CollectedPage, Collecting, OccurrenceMap,
         PageContent].each do |klass|
          klass.where(page_id: bad_pages).delete_all
        end
        Page.where(id: bad_pages).delete_all
      end
    end
def remove_if_nodeless Page . find_in_batches ( batch_size : 10_000 ) do | group | group_ids = group . map ( & :id ) have_ids = Node . where ( page_id : group_ids ) . pluck ( :page_id ) bad_pages = group_ids - have_ids next if bad_pages . empty? [ PageIcon , ScientificName , SearchSuggestion , Vernacular , CollectedPage , Collecting , OccurrenceMap , PageContent ] . each do | klass | klass . where ( page_id : bad_pages ) . delete_all end Page . where ( id : bad_pages ) . delete_all end end
Occasionally you'll see "NO NAME" for some page IDs (in searches, associations, collections, and so on), and this
can be caused by the native_node_id being set to a node that no longer exists.
Occasionally you ' ll see " NO NAME " for some page IDs ( in searches associations collections and so on ) and this can be caused by the native_node_id being set to a node that no longer exists .
# Delete pages that no longer have nodes # TODO: PagesReferent