Class: Eco::API::UseCases::Default::People::Amend::RestoreDBCase

Inherits:
Common::Loaders::UseCase show all
Defined in:
lib/eco/api/usecases/default/people/amend/restore_db_case.rb,
lib/eco/api/usecases/default/people/amend/cli/restore_db_cli.rb

Overview

Examples:

-restore-db-from backup.json -skip-api-policies -skip-batch-policy -include-excluded -simulate

Defined Under Namespace

Classes: Cli

Instance Attribute Summary

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods inherited from Common::Loaders::UseCase

cli, cli!, #cli_apply!, #initialize, type, #type

Methods inherited from Common::Loaders::CaseBase

#name, name_only_once!

Methods inherited from Common::Loaders::Base

<=>, created_at, #initialize, set_created_at!

Methods included from Common::ClassHelpers

#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant

Methods included from Language::AuxiliarLogger

#log

Constructor Details

This class inherits a constructor from Eco::API::Common::Loaders::UseCase

Instance Method Details

#main(entries, people, session, options, usecase) ⇒ Object

rubocop:disable Metrics/AbcSize



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/eco/api/usecases/default/people/amend/restore_db_case.rb', line 9

def main(entries, people, session, options, usecase) # rubocop:disable Metrics/AbcSize
  require_people_as_entries!(entries)

  restart  = session.new_job("main", "restart", :create, usecase) if options.dig(:include, :create)
  update   = session.new_job("main", "update",  :update, usecase)
  delete   = session.new_job("main", "delete",  :update, usecase)

  if options.dig(:include, :delete)
    micro.with_each_leaver(entries, people, options) do |person|
      delete.add(person)
    end
  end

  re_starters = []

  micro.with_each(entries, people, options) do |entry, person|
    if person.new? && !options.dig(:include, :create)
      re_starters.push(entry)
      next
    end

    person.new? ? restart.add(person) : update.add(person)

    core_copy(entry, person)       unless options.dig(:exclude, :core)
    person.details = entry.details unless options.dig(:exclude, :details)

    unless options.dig(:exclude, :account) || !entry.
      person. ||= {}
      (entry., person.)
    end
  end

  report_re_starters(re_starters)
end