app/models/support/sanity_check.rb
# find all the studies which are orphaned
find all the studies which are orphaned
find all the studies which are orphaned
def check_for_orphans
      parent_children_relationships.each do |r|
        parent = r.first
        child = r.last
        query = self.orphan_check_sql(parent,child)
        counter = 0
        ActiveRecord::Base.connection.execute(query).each do |orphan|
          counter += 1
          Support::SanityCheck.create(
            nct_id: orphan['nct_id'],
            table_name: child,
            check_type: 'orphan',
            description: "Orphaned from #{parent}",
            most_current: true
          )
          return if cntr > 100  
        end
      end
    end
def check_for_orphans parent_children_relationships . each do | r | parent = r . first child = r . last query = self . orphan_check_sql ( parent , child ) counter = 0 ActiveRecord :: Base . connection . execute ( query ) . each do | orphan | counter += 1 Support :: SanityCheck . create ( nct_id : orphan [ 'nct_id' ] , table_name : child , check_type : 'orphan' , description : "Orphaned from #{parent}" , most_current : true ) return if cntr > 100 end end end
find all the studies which are orphaned
find all the studies which are orphaned
# if a widespread problem, we just need to see some examples