Refactoring: Splitted up instance_action statistics diff for different usages.
This commit is contained in:
parent
00f0bd8212
commit
ab0e64d3a9
5 changed files with 62 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
||||||
require 'sequencer/unit/import/common/model/statistics/mixin/diff'
|
require 'sequencer/unit/import/common/model/statistics/mixin/instance_action_diff'
|
||||||
|
|
||||||
class Sequencer
|
class Sequencer
|
||||||
class Unit
|
class Unit
|
||||||
|
@ -7,7 +7,7 @@ class Sequencer
|
||||||
module Model
|
module Model
|
||||||
module Statistics
|
module Statistics
|
||||||
class Diff < Sequencer::Unit::Base
|
class Diff < Sequencer::Unit::Base
|
||||||
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::Diff
|
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::InstanceActionDiff
|
||||||
|
|
||||||
def process
|
def process
|
||||||
state.provide(:statistics_diff, diff)
|
state.provide(:statistics_diff, diff)
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
class Sequencer
|
||||||
|
class Unit
|
||||||
|
module Import
|
||||||
|
module Common
|
||||||
|
module Model
|
||||||
|
module Statistics
|
||||||
|
module Mixin
|
||||||
|
module Common
|
||||||
|
private
|
||||||
|
|
||||||
|
def actions
|
||||||
|
%i[skipped created updated unchanged failed deactivated]
|
||||||
|
end
|
||||||
|
|
||||||
|
def empty_diff
|
||||||
|
possible_actions.collect { |key| [key, 0] }.to_h
|
||||||
|
end
|
||||||
|
|
||||||
|
def possible_actions
|
||||||
|
@possible_actions ||= actions
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,25 @@
|
||||||
|
require 'sequencer/unit/import/common/model/statistics/mixin/common'
|
||||||
|
|
||||||
|
class Sequencer
|
||||||
|
class Unit
|
||||||
|
module Import
|
||||||
|
module Common
|
||||||
|
module Model
|
||||||
|
module Statistics
|
||||||
|
module Mixin
|
||||||
|
module EmptyDiff
|
||||||
|
include Sequencer::Unit::Import::Common::Model::Statistics::Mixin::Common
|
||||||
|
|
||||||
|
def self.included(base)
|
||||||
|
base.provides :statistics_diff
|
||||||
|
end
|
||||||
|
|
||||||
|
alias diff empty_diff
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'sequencer/unit/import/common/model/statistics/mixin/common'
|
||||||
|
|
||||||
class Sequencer
|
class Sequencer
|
||||||
class Unit
|
class Unit
|
||||||
module Import
|
module Import
|
||||||
|
@ -5,7 +7,8 @@ class Sequencer
|
||||||
module Model
|
module Model
|
||||||
module Statistics
|
module Statistics
|
||||||
module Mixin
|
module Mixin
|
||||||
module Diff
|
module InstanceActionDiff
|
||||||
|
include Sequencer::Unit::Import::Common::Model::Statistics::Mixin::Common
|
||||||
|
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.uses :instance_action
|
base.uses :instance_action
|
||||||
|
@ -14,13 +17,9 @@ class Sequencer
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def actions
|
|
||||||
%i[skipped created updated unchanged failed deactivated]
|
|
||||||
end
|
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
raise "Unknown action '#{instance_action}'" if !possible?
|
raise "Unknown action '#{instance_action}'" if !possible?
|
||||||
defaults.merge(
|
empty_diff.merge(
|
||||||
instance_action => 1,
|
instance_action => 1,
|
||||||
sum: 1,
|
sum: 1,
|
||||||
)
|
)
|
||||||
|
@ -29,14 +28,6 @@ class Sequencer
|
||||||
def possible?
|
def possible?
|
||||||
possible_actions.include?(instance_action)
|
possible_actions.include?(instance_action)
|
||||||
end
|
end
|
||||||
|
|
||||||
def defaults
|
|
||||||
possible_actions.collect { |key| [key, 0] }.to_h
|
|
||||||
end
|
|
||||||
|
|
||||||
def possible_actions
|
|
||||||
@possible_actions ||= actions
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -5,7 +5,7 @@ class Sequencer
|
||||||
module FolderContact
|
module FolderContact
|
||||||
module Statistics
|
module Statistics
|
||||||
class Diff < Sequencer::Unit::Base
|
class Diff < Sequencer::Unit::Base
|
||||||
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::Diff
|
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::InstanceActionDiff
|
||||||
|
|
||||||
uses :ews_folder_name
|
uses :ews_folder_name
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue