Sha256: 1b3b190bc110683c7445adcf12c1a3b3be806c007c05d0c8e52058beda32c848
Contents?: true
Size: 1.68 KB
Versions: 12
Compression:
Stored size: 1.68 KB
Contents
module Eco module API class UseCases class DefaultCases class SetDefaultTagCase < DefaultCase # take the deepest tag (the one that is further down in the tree) # different options (several nodes at the same depth): # => take the common node between them (i.e. you have Hamilton and Auckland -> take New Zealand) # => if there's no common node between them, take the `first` (unless they are at top level of the tree) def process @cases.define("set-default-tag", type: :transform) do |people, session, options, usecase| if !session.tagtree msg = "There is no tagtree definition in the configuration files\n" + "For this usecase to work out you need to define it." session.logger.fatal(msg) exit end # IMPORTANT: this two lines ensure that only people to be updated is selected all_people = people people = people.account_present if people.length <= 0 session.logger.info("There are no people with account... aborting script") exit end update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: :account) people.each_with_index do |person, i| #next unless person.id == "5c527ba63f7690001243f5b2" person.account.default_tag = session.tagtree.default_tag(*person.filter_tags) update.add(person) end end end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems