This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Job < ActiveRecord::Base | |
has_many :requirements | |
has_many :required_jobs, :source => :derived_job, :through => :requirements | |
has_many :derived_jobs, :source => :required_job, :through => :requirements | |
end | |
class Requirement < ActiveRecord::Base | |
belongs_to :derived_job, :class_name => "Job" | |
belongs_to :required_job, :class_name => "Job" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SQL_CALC_FOUND_ROWS o.*, | |
(CASE TRUNCATE(( | |
SELECT (SUM(oi.case_or_pack)/COUNT(*)) | |
FROM order_items as oi, orders as o | |
WHERE o.order_id = oi.order_id) | |
,2) | |
WHEN 2.00 | |
THEN "CA" | |
WHEN 1.00 | |
THEN "EA" |