Created
March 12, 2013 13:44
-
-
Save rodrigoulisses/5142957 to your computer and use it in GitHub Desktop.
MileageSearcher
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 MileageSearcher | |
include Quaestio | |
repository Mileage | |
def organogram_id(organogram_id) | |
where { self.organogram_id.eq(organogram_id) } | |
end | |
def driver_id(driver_id) | |
where { self.driver_id.eq(driver_id) } | |
end | |
def vehicle_id(vehicle_id) | |
where { self.vehicle_id.eq(vehicle_id) } | |
end | |
def type_of_vehicle(type_of_vehicle) | |
joins { vehicle }.where { vehicle.type_of_vehicle.eq(type_of_vehicle) } | |
end | |
def subtype_of_vehicle(subtype_of_vehicle) | |
joins { vehicle }.where { vehicle.subtype_of_vehicle.eq(subtype_of_vehicle) } | |
end | |
def type_of_vehicle_control(type_of_vehicle_control) | |
joins { vehicle }.where { vehicle.type_of_vehicle_control.eq(type_of_vehicle_control) } | |
end | |
def start_date(start_date) | |
where { date_of_output >= start_date } | |
end | |
def end_date(end_date) | |
where { date_of_arrival <= end_date } | |
end | |
def ordered_by(ordered) | |
order { organogram } if ordered == MileageControlGroup::ORGANOGRAM | |
order { driver } if ordered == MileageControlGroup::DRIVER | |
order { vehicle } if ordered == MileageControlGroup::VEHICLE | |
order { control } if ordered == MileageControlGroup::CONTROL | |
order { date_of_output } if ordered == MileageControlGroup::INITIAL_DATE | |
order { date_of_arrival } if ordered == MileageControlGroup::END_DATE | |
end | |
def grouped(grouped_option) | |
group { organogram } if grouped_option.eql? MileageControlGroup::ORGANOGRAM | |
group { driver } if grouped_option.eql? MileageControlGroup::DRIVER | |
group { vehicle } if grouped_option.eql? MileageControlGroup::VEHICLE | |
group { control } if grouped_option.eql? MileageControlGroup::CONTROL | |
group { initial_date } if grouped_option.eql? MileageControlGroup::INITIAL_DATE | |
group { end_date } if grouped_option.eql? MileageControlGroup::END_DATE | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment