diff options
| author | Zakaria BOUZIANE | 2015-03-09 14:01:10 +0100 | 
|---|---|---|
| committer | Zakaria BOUZIANE | 2015-03-09 14:01:10 +0100 | 
| commit | 0d5adf2fad5c0ddd8efc1eca9dc6d8e9c48b049d (patch) | |
| tree | 36e3d37edd325d59b6056c738305d5d60f74beee /app/models/vehicle_identifier.rb | |
| parent | f0456f7334b8fb4442a51bb370fdc0c5a3ea2cd0 (diff) | |
| download | chouette-core-0d5adf2fad5c0ddd8efc1eca9dc6d8e9c48b049d.tar.bz2 | |
Prepare merging V2_5 into V3
Diffstat (limited to 'app/models/vehicle_identifier.rb')
| -rw-r--r-- | app/models/vehicle_identifier.rb | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/vehicle_identifier.rb b/app/models/vehicle_identifier.rb new file mode 100644 index 000000000..f53725c74 --- /dev/null +++ b/app/models/vehicle_identifier.rb @@ -0,0 +1,16 @@ +class VehicleIdentifier + +  def self.auto_identify_vehicles + +    #max_identifier = Chouette::VehicleJourney. +    Chouette::VehicleJourney.transaction do +      vehicles = Chouette::VehicleJourney.lock(true).all +      max = vehicles.map(&:vehicle_type_identifier).compact.map(&:to_i).max + +      vehicles.select {|v| v.vehicle_type_identifier.nil? }.each_with_index do |v, index| +        v.update_attributes :vehicle_type_identifier => ( max.to_i + index + 1) +      end +    end +  end + +end  | 
