lib/quality/repositories/qc_repo.rb
# Given a delivery, check if there is a sample of the given type
# for the delivery's combination of season, cultivar and orchard.
Given a delivery, check if there is a sample of the given type
for the delivery's combination of season, cultivar and orchard.
Given a delivery check if there is a sample of the given type for the delivery ' s combination of season cultivar and orchard .
def rmt_delivery_has_first_sample?(rmt_delivery_id, sample_type)
      season_id, cultivar_id, orchard_id = get(:rmt_deliveries, %i[season_id cultivar_id orchard_id], rmt_delivery_id)
      query = <<~SQL
        SELECT s.id
        FROM qc_samples s
        JOIN qc_sample_types t ON t.id = s.qc_sample_type_id
        JOIN rmt_deliveries r ON r.id = s.rmt_delivery_id
        WHERE t.qc_sample_type_name = ?
          AND r.season_id = ?
          AND r.cultivar_id = ?
          AND r.orchard_id = ?
      SQL
      !DB[query, sample_type, season_id, cultivar_id, orchard_id].first.nil?
    end
def rmt_delivery_has_first_sample? ( rmt_delivery_id , sample_type ) season_id , cultivar_id , orchard_id = get ( :rmt_deliveries , %i[ season_id cultivar_id orchard_id ] , rmt_delivery_id ) query = <<~SQL 
        SELECT s.id
        FROM qc_samples s
        JOIN qc_sample_types t ON t.id = s.qc_sample_type_id
        JOIN rmt_deliveries r ON r.id = s.rmt_delivery_id
        WHERE t.qc_sample_type_name = ?
          AND r.season_id = ?
          AND r.cultivar_id = ?
          AND r.orchard_id = ?
       SQL ! DB [ query , sample_type , season_id , cultivar_id , orchard_id ] . first . nil? end
Given a delivery, check if there is a sample of the given type
for the delivery's combination of season, cultivar and orchard.
Given a delivery check if there is a sample of the given type for the delivery ' s combination of season cultivar and orchard .
rmt_delivery_id
<not_specific>
sample_type
<not_specific>