model/systematic_review_views_mixin.rb
def cd_id_table
    view_name = cd_id_table_tn
    if @cd_id_table_tn_exists.nil?
      @cd_id_table_tn_exists=true
      if !$db.table_exists?(view_name)
        $db.run("CREATE VIEW #{view_name} AS SELECT DISTINCT(r.canonical_document_id) FROM records r INNER JOIN records_searches br ON r.id=br.record_id INNER JOIN searches b ON br.search_id=b.id WHERE b.systematic_review_id=#{self[:id]} AND b.valid=1

        UNION

        SELECT DISTINCT r.canonical_document_id FROM searches b INNER JOIN records_searches br ON b.id=br.search_id INNER JOIN records_references rr ON br.record_id=rr.record_id INNER JOIN bib_references r ON rr.reference_id=r.id  WHERE b.systematic_review_id=#{self[:id]} and r.canonical_document_id IS NOT NULL and b.valid=1 GROUP BY r.canonical_document_id")
      end
    end
    $db[view_name.to_sym]
  end
# Entrega todos los id pertinentes para la revision sistematica
Entrega todos los id pertinentes para la revision sistematica
Entrega todos los id pertinentes para la revision sistematica
def cd_id_table
    view_name = cd_id_table_tn
    if @cd_id_table_tn_exists.nil?
      @cd_id_table_tn_exists=true
      if !$db.table_exists?(view_name)
        $db.run("CREATE VIEW #{view_name} AS SELECT DISTINCT(r.canonical_document_id) FROM records r INNER JOIN records_searches br ON r.id=br.record_id INNER JOIN searches b ON br.search_id=b.id WHERE b.systematic_review_id=#{self[:id]} AND b.valid=1
        UNION
        SELECT DISTINCT r.canonical_document_id FROM searches b INNER JOIN records_searches br ON b.id=br.search_id INNER JOIN records_references rr ON br.record_id=rr.record_id INNER JOIN bib_references r ON rr.reference_id=r.id  WHERE b.systematic_review_id=#{self[:id]} and r.canonical_document_id IS NOT NULL and b.valid=1 GROUP BY r.canonical_document_id")
      end
    end
    $db[view_name.to_sym]
  end
def cd_id_table view_name = cd_id_table_tn if @cd_id_table_tn_exists . nil? @cd_id_table_tn_exists = true if ! $db . table_exists? ( view_name ) $db . run ( "CREATE VIEW #{view_name} AS SELECT DISTINCT(r.canonical_document_id) FROM records r INNER JOIN records_searches br ON r.id=br.record_id INNER JOIN searches b ON br.search_id=b.id WHERE b.systematic_review_id=#{self[:id]} AND b.valid=1

        UNION

        SELECT DISTINCT r.canonical_document_id FROM searches b INNER JOIN records_searches br ON b.id=br.search_id INNER JOIN records_references rr ON br.record_id=rr.record_id INNER JOIN bib_references r ON rr.reference_id=r.id  WHERE b.systematic_review_id=#{self[:id]} and r.canonical_document_id IS NOT NULL and b.valid=1 GROUP BY r.canonical_document_id" ) end end $db [ view_name . to_sym ] end
Entrega todos los id pertinentes para la revision sistematica
Entrega todos los id pertinentes para la revision sistematica