Class: Eco::API::UseCases::OozeSamples::RegisterUpdateCase

Inherits:
OozeBaseCase show all
Defined in:
lib/eco/api/usecases/ooze_samples/register_update_case.rb

Overview

Note:
  • You can define methods filters and search to change the target entries of the register
  • You need to define the process_ooze method

Use case to update a register This case expects options[:source][:register_id]

Direct Known Subclasses

RegisterMigrationCase, TargetOozesUpdateCase

Constant Summary

Constants inherited from OozeBaseCase

OozeBaseCase::DRY_COUNT, OozeBaseCase::SAVE_PATCH

Constants included from Helpers::Filters

Helpers::Filters::FILTER_TIME_FORMAT

Instance Attribute Summary collapse

Attributes inherited from OozeBaseCase

#options, #session, #target, #usecase

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Filters

#date_range_filter, #days, #daystart, #field_key_name, #midnight, #previous_sunday, #set_time, #sunday, #tags_filter, #this_monday, #to_date_filter, #today, #weeks

Methods included from Helpers::Shortcuts

#bracked_regex, #clean_question, #is_number?, #non_letters_regex, #normalize_string, #object_reference, #same_string?, #simplify_string, #titleize, #to_i

Methods inherited from Common::Loaders::UseCase

#initialize, type, #type

Methods inherited from Common::Loaders::CaseBase

#name, name_only_once!

Methods inherited from Common::Loaders::Base

<=>, created_at, #initialize, #name, 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

Constructor Details

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

Instance Attribute Details

#created_oozesObject (readonly)

Returns the value of attribute created_oozes.



22
23
24
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 22

def created_oozes
  @created_oozes
end

#dupped_search_oozesObject (readonly)

Returns the value of attribute dupped_search_oozes.



21
22
23
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 21

def dupped_search_oozes
  @dupped_search_oozes
end

#failed_update_oozesObject (readonly)

Returns the value of attribute failed_update_oozes.



22
23
24
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 22

def failed_update_oozes
  @failed_update_oozes
end

#non_retrieved_oozesObject (readonly)

Returns the value of attribute non_retrieved_oozes.



20
21
22
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 20

def non_retrieved_oozes
  @non_retrieved_oozes
end

#ooze_result_idsObject (readonly)

Returns the value of attribute ooze_result_ids.



22
23
24
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 22

def ooze_result_ids
  @ooze_result_ids
end

#retrieved_oozesObject (readonly)

Returns the value of attribute retrieved_oozes.



20
21
22
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 20

def retrieved_oozes
  @retrieved_oozes
end

#total_search_oozesObject (readonly)

Returns the value of attribute total_search_oozes.



21
22
23
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 21

def total_search_oozes
  @total_search_oozes
end

#updated_oozesObject (readonly)

Returns the value of attribute updated_oozes.



22
23
24
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 22

def updated_oozes
  @updated_oozes
end

Class Method Details

.batch_size(size = nil) ⇒ Integer

Returns the number of pages to be processed in each batch.

Returns:

  • (Integer)

    the number of pages to be processed in each batch



10
11
12
13
14
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 10

def batch_size(size = nil)
  @batch_size ||= 25
  return @batch_size unless size
  @batch_size = size
end

Instance Method Details

#main(session, options, usecase, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 24

def main(session, options, usecase, &block)
  @retrieved_oozes = 0
  @non_retrieved_oozes = 0
  @dupped_search_oozes = 0
  @ooze_result_ids     = {}
  @updated_oozes       = 0
  @failed_update_oozes = 0
  @created_oozes       = 0

  super(session, options, usecase) do
    with_each_entry do |ooze|
      process_ooze(&block)
    end
  end
  msg  = "Run end:\n"
  msg += "  • Search results: #{total_search_oozes}\n"
  msg += "  • Duplicated search results #{dupped_search_oozes}\n"
  msg += "  • Retrieved a total of #{retrieved_oozes}\n"
  msg += "  • Could not get #{non_retrieved_oozes} oozes.\n"
  msg += "  • Updated #{updated_oozes} oozes.\n"
  msg += "    - Failed update on #{failed_update_oozes} oozes.\n"
  msg += "  • Created #{created_oozes} oozes.\n"
  logger.info(msg)
end

#process_ooze(ooze = target) ⇒ Object



49
50
51
# File 'lib/eco/api/usecases/ooze_samples/register_update_case.rb', line 49

def process_ooze(ooze = target)
  raise "You need to define this method"
end