diff options
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/concerns/report_concern.rb | 26 | ||||
| -rw-r--r-- | app/models/export.rb | 8 | ||||
| -rw-r--r-- | app/models/gtfs_import.rb | 1 | ||||
| -rw-r--r-- | app/models/hub_export.rb | 3 | ||||
| -rw-r--r-- | app/models/import.rb | 39 | ||||
| -rw-r--r-- | app/models/neptune_export.rb | 3 | 
6 files changed, 59 insertions, 21 deletions
| diff --git a/app/models/concerns/report_concern.rb b/app/models/concerns/report_concern.rb index 2c4901566..7d3efff24 100644 --- a/app/models/concerns/report_concern.rb +++ b/app/models/concerns/report_concern.rb @@ -101,13 +101,31 @@ module ReportConcern    class LineItem -    attr_reader :name, :status, :stats +    attr_reader :options      def initialize( options ) -      @name = options.name if options.name? -      @status = options.status if options.status? -      @stats = options.stats if options.stats? +      @options = options      end + +    def name +      @name ||= options.name if options.name? +    end + +    def stats +      @stats ||= options.stats if options.stats? +    end + +    def status +      @status ||= if options.status?         +                    if %w{ok warning}.include? options.status.downcase +                      true +                    else +                      false +                    end                     +                  else +                    false +                  end +    end           def routes        stats ? stats.route_count : 0 diff --git a/app/models/export.rb b/app/models/export.rb index ee008d590..c3895ffc5 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -1,5 +1,9 @@  class Export    include JobConcern + +  def report? +    links["action_report"].present? +  end    def report      Rails.cache.fetch("#{cache_key}/action_report", expires_in: cache_expiration) do @@ -26,6 +30,10 @@ class Export      end    end +  def file_path? +    links["data"].present? +  end +      def file_path      links["data"]    end diff --git a/app/models/gtfs_import.rb b/app/models/gtfs_import.rb index a0e5ee10b..25eb670df 100644 --- a/app/models/gtfs_import.rb +++ b/app/models/gtfs_import.rb @@ -5,7 +5,6 @@ class GtfsImport < ImportTask    attr_accessor :object_id_prefix, :max_distance_for_commercial, :ignore_last_word,  :ignore_end_chars, :max_distance_for_connection_link, :references_type    validates_presence_of :object_id_prefix -  validates_presence_of :references_type    def references_types      self.references_type.values diff --git a/app/models/hub_export.rb b/app/models/hub_export.rb index c0709cc1d..dcbfc01a1 100644 --- a/app/models/hub_export.rb +++ b/app/models/hub_export.rb @@ -2,9 +2,6 @@ class HubExport < ExportTask    attr_accessor :start_date, :end_date    enumerize :references_type, in: %w( network line company group_of_line ) - -  validates :start_date, presence: true , if: "end_date.present?"    -  validates :end_date, presence: true, if: "start_date.present?"     after_initialize :init_period diff --git a/app/models/import.rb b/app/models/import.rb index be469d282..733795bd8 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -2,17 +2,24 @@ require 'open-uri'  class Import    include JobConcern + +  # def compliance_check_validation_report? +  # end -  def compliance_check_validation_report -    Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do -      report_path = links["validation_report"] -      if report_path -        response = Ievkit.get(report_path) -        ComplianceCheckResult.new(response) -      else -        raise Ievkit::IevError("Impossible to access report path link for validation of import") -      end -    end +  # def compliance_check_validation_report +  #   Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do +  #     report_path = links["validation_report"] +  #     if report_path +  #       response = Ievkit.get(report_path) +  #       ComplianceCheckResult.new(response) +  #     else +  #       raise Ievkit::IevError("Impossible to access report path link for validation of import") +  #     end +  #   end +  # end + +  def report? +    links["action_report"].present?    end    def report @@ -27,6 +34,10 @@ class Import      end    end  +  def rule_parameter_set? +    links["validation_params"].present? +  end +      def rule_parameter_set      Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do        rule_parameter_set_path = links["validation_params"] @@ -37,6 +48,10 @@ class Import        end      end    end + +  def compliance_check? +    links["validation_report"].present? +  end    def compliance_check      Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do @@ -62,6 +77,10 @@ class Import      end    end +  def file_path? +    links["data"].present? +  end +      def file_path      links["data"]    end diff --git a/app/models/neptune_export.rb b/app/models/neptune_export.rb index 45c2aa4ea..8e9d91557 100644 --- a/app/models/neptune_export.rb +++ b/app/models/neptune_export.rb @@ -2,9 +2,6 @@ class NeptuneExport < ExportTask    attr_accessor :start_date, :end_date, :extensions, :export_type    enumerize :references_type, in: %w( network line company group_of_line ) - -  validates :start_date, presence: true , if: "end_date.present?"    -  validates :end_date, presence: true, if: "start_date.present?"     def action_params      { | 
