Sha256: f90aaeb46071a4e4355466ba4623b49f8619eef9d3551f25ae5ce99eae995cf3

Contents?: true

Size: 931 Bytes

Versions: 26

Compression:

Stored size: 931 Bytes

Contents

class Eco::API::UseCases::DefaultCases::CleanUnknownTags < Eco::API::Common::Loaders::UseCase
  name "clean-unknown-tags"
  type :transform

  REGISTER_TAGS = [
    "EVENT", "INJURY", "RISK", "CONTRACTOR", "PERMIT",
    "AUDIT", "JSEA",
    "TRAINING", "INDUCTION",
    "MEETING",  "PPE",  "CHEMICAL",
    "PLANT", "ASSET",
    "POLICY", "IDEA", "REPORTS"
  ]

  attr_reader :session, :options

  def main(people, session, options, usecase)
    @session = session; @options = options

    update   = session.new_job("main", "update", :update, usecase)
    people.each do |person|
      unknown_tags = person.filter_tags.select {|tag| !tag?(tag)}
      person.filter_tags -= unknown_tags
      update.add(person)
    end
  end

  private

  def tag?(value)
    tagtree.tag?(value) || REGISTER_TAGS.any? {|reg| value == reg}
  end

  def tagtree
    @tagtree ||= ASSETS.config.tagtree
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
eco-helpers-2.0.46 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.45 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.44 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.43 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.42 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.41 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.40 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.39 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.38 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.37 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.36 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.35 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.34 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.33 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.32 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.31 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.30 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.29 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.28 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb
eco-helpers-2.0.27 lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb