diff options
| author | Zakaria BOUZIANE | 2015-03-10 12:04:25 +0100 |
|---|---|---|
| committer | Zakaria BOUZIANE | 2015-03-10 12:04:25 +0100 |
| commit | e3cd779d28af135dc32b25ba249be48ebf6658bf (patch) | |
| tree | 5f59356149e5eb58f7bf9459db5c2229a0d278ca /app/models | |
| parent | 8d9281dcc994ad76092b4878b26801507915f16a (diff) | |
| parent | dc6fc17f5ea46c871154e398037fab3bb741504e (diff) | |
| download | chouette-core-e3cd779d28af135dc32b25ba249be48ebf6658bf.tar.bz2 | |
Merged code
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/import.rb | 14 | ||||
| -rw-r--r-- | app/models/import_report.rb | 103 |
2 files changed, 111 insertions, 6 deletions
diff --git a/app/models/import.rb b/app/models/import.rb index 7b2405db2..f1d6169f1 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -9,20 +9,28 @@ class Import attr_reader :datas, :report def initialize( options = Hashie::Mash.new ) - puts "options #{options.inspect}" @datas = options @status = @datas.status.downcase if @datas.status? @format = @datas.type.downcase if @datas.type? end def report - ImportReport.new( IevApi.job(referential_name, id,{ :action => "importer" }) ) + result = IevApi.job(referential_name, id,{ :action => "importer" }) + ImportReport.new( result ) end def id @datas.id end + def filename + @datas.filename + end + + def filename_extension + File.extname(filename) if filename + end + def percentage_progress if %w{created}.include? status 0 @@ -38,7 +46,7 @@ class Import end def referential_name - @datas.parameters.referential + @datas.referential end def name diff --git a/app/models/import_report.rb b/app/models/import_report.rb index 8ec112dc3..50857b4e7 100644 --- a/app/models/import_report.rb +++ b/app/models/import_report.rb @@ -1,7 +1,4 @@ class ImportReport - extend Enumerize - extend ActiveModel::Naming - include ActiveModel::Model attr_reader :datas @@ -9,4 +6,104 @@ class ImportReport @datas = options end + def zip_file + datas.zip_file + end + + def error_files + datas.files.select{ |file| file[:status] == "ERROR"} + end + + def ignored_files + datas.files.select{ |file| file[:status] == "IGNORED"} + end + + def ok_files + datas.files.select{ |file| file[:status] == "OK"} + end + + def files + datas.files + end + + def line_items + [].tap do |line_items| + datas.lines.each do |line| + line_items << LineItem.new(line) + end + end + end + + def lines + 1 #datas.stats.line_count if datas.stats_.line_count? + end + + def routes + datas.stats.route_count if datas.stats_.route_count? + end + + def connection_links + datas.stats.connection_link_count if datas.stats_.connection_link_count? + end + + def time_tables + datas.stats.time_table_count if datas.stats_.time_table_count? + end + + def stop_areas + datas.stats.stop_area_count if datas.stats_.stop_area_count? + end + + def access_points + datas.stats.access_point_count if datas.stats_.access_point_count? + end + + def vehicle_journeys + datas.stats.vehicle_journey_count if datas.stats_.vehicle_journey_count? + end + + def journey_patterns + datas.stats.journey_pattern_count if datas.stats_.journey_pattern_count? + end + + class LineItem + attr_reader :name, :status, :stats + + def initialize( options = Hashie::Mash.new ) + @name = options.name if options.name? + @status = options.status if options.status? + @stats = options.stats if options.stats? + end + + def routes + stats.route_count + end + + def connection_links + stats.connection_link_count + end + + def time_tables + stats.time_table_count + end + + def stop_areas + stats.stop_area_count + end + + def access_points + stats.access_point_count + end + + def vehicle_journeys + stats.vehicle_journey_count + end + + def journey_patterns + stats.journey_pattern_count + end + + end + end + |
