Class: NewStoreApi::RoutingDecisionTrace

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/routing_decision_trace.rb

Overview

Optional decision trace explaining how routing chose placements.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(after_filters_sorted_row = nil, fetchers_snapshot = nil, filter_steps = nil, initial_location_row = nil, picked = nil, reducer_steps = nil, strategy = nil, version = nil) ⇒ RoutingDecisionTrace

Returns a new instance of RoutingDecisionTrace.



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 68

def initialize(after_filters_sorted_row = nil, fetchers_snapshot = nil,
               filter_steps = nil, initial_location_row = nil, picked = nil,
               reducer_steps = nil, strategy = nil, version = nil)
  @after_filters_sorted_row = after_filters_sorted_row
  @fetchers_snapshot = fetchers_snapshot
  @filter_steps = filter_steps
  @initial_location_row = initial_location_row
  @picked = picked
  @reducer_steps = reducer_steps
  @strategy = strategy
  @version = version
end

Instance Attribute Details

#after_filters_sorted_rowObject

Location weights after filters, sorted for display.

Returns:

  • (Object)


14
15
16
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 14

def after_filters_sorted_row
  @after_filters_sorted_row
end

#fetchers_snapshotObject

Snapshot of fetcher inputs used for the simulation run.

Returns:

  • (Object)


18
19
20
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 18

def fetchers_snapshot
  @fetchers_snapshot
end

#filter_stepsArray[Object]

Filter steps applied during routing.

Returns:

  • (Array[Object])


22
23
24
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 22

def filter_steps
  @filter_steps
end

#initial_location_rowObject

Initial location weights before filters.

Returns:

  • (Object)


26
27
28
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 26

def initial_location_row
  @initial_location_row
end

#pickedRoutingDecisionTracePicked

Selected routing logic candidate in the decision trace.



30
31
32
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 30

def picked
  @picked
end

#reducer_stepsArray[Object]

Reducer steps applied to candidate routing results.

Returns:

  • (Array[Object])


34
35
36
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 34

def reducer_steps
  @reducer_steps
end

#strategyObject

Strategy execution details for the simulation.

Returns:

  • (Object)


38
39
40
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 38

def strategy
  @strategy
end

#versionInteger

Decision trace schema version.

Returns:

  • (Integer)


42
43
44
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 42

def version
  @version
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  after_filters_sorted_row =
    hash.key?('after_filters_sorted_row') ? hash['after_filters_sorted_row'] : nil
  fetchers_snapshot =
    hash.key?('fetchers_snapshot') ? hash['fetchers_snapshot'] : nil
  filter_steps = hash.key?('filter_steps') ? hash['filter_steps'] : nil
  initial_location_row =
    hash.key?('initial_location_row') ? hash['initial_location_row'] : nil
  picked = RoutingDecisionTracePicked.from_hash(hash['picked']) if hash['picked']
  reducer_steps = hash.key?('reducer_steps') ? hash['reducer_steps'] : nil
  strategy = hash.key?('strategy') ? hash['strategy'] : nil
  version = hash.key?('version') ? hash['version'] : nil

  # Create object from extracted values.
  RoutingDecisionTrace.new(after_filters_sorted_row,
                           fetchers_snapshot,
                           filter_steps,
                           initial_location_row,
                           picked,
                           reducer_steps,
                           strategy,
                           version)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['after_filters_sorted_row'] = 'after_filters_sorted_row'
  @_hash['fetchers_snapshot'] = 'fetchers_snapshot'
  @_hash['filter_steps'] = 'filter_steps'
  @_hash['initial_location_row'] = 'initial_location_row'
  @_hash['picked'] = 'picked'
  @_hash['reducer_steps'] = 'reducer_steps'
  @_hash['strategy'] = 'strategy'
  @_hash['version'] = 'version'
  @_hash
end

.nullablesObject

An array for nullable fields



64
65
66
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 64

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 59

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



119
120
121
122
123
124
125
126
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 119

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} after_filters_sorted_row: #{@after_filters_sorted_row.inspect},"\
  " fetchers_snapshot: #{@fetchers_snapshot.inspect}, filter_steps: #{@filter_steps.inspect},"\
  " initial_location_row: #{@initial_location_row.inspect}, picked: #{@picked.inspect},"\
  " reducer_steps: #{@reducer_steps.inspect}, strategy: #{@strategy.inspect}, version:"\
  " #{@version.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



110
111
112
113
114
115
116
# File 'lib/new_store_api/models/routing_decision_trace.rb', line 110

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} after_filters_sorted_row: #{@after_filters_sorted_row}, fetchers_snapshot:"\
  " #{@fetchers_snapshot}, filter_steps: #{@filter_steps}, initial_location_row:"\
  " #{@initial_location_row}, picked: #{@picked}, reducer_steps: #{@reducer_steps}, strategy:"\
  " #{@strategy}, version: #{@version}>"
end