Class: Eco::API::UseCases::GraphQL::Compat::Parity::RunResult

Inherits:
Object
  • Object
show all
Defined in:
lib/eco/api/usecases/graphql/compat/parity/run_result.rb

Overview

A normalised, comparable snapshot of ONE use-case run.

The A/B parity harness reduces a run — whether it went through the legacy (v2 / OozeRedirect) path or the native GraphQL path — to just its OBSERVABLE outcome:

  • kpis — the KPI counter hash (search/retrieved/updated/created/… )
  • updates — the per-page update payload the run WOULD send, keyed by page id

Two runs are "equivalent" when, after normalisation, both are identical. This is the unit the strangler-fig migration is gated on: flip a case name only once its native RunResult matches the legacy RunResult over the same input.

Everything here is PURE (no session, no network) so equivalence can be asserted offline in specs; the live capture step (feeding real runs in) is the only part that needs credentials.

Constant Summary collapse

CANON_KPI_ALIASES =

KPI names differ between the legacy and native cases (e.g. updated_oozes vs updated_pages). We compare on a CANONICAL subset of counters that both sides expose the same way, mapping each side's names onto the canon.

{
  search:     %i[total_search_oozes total_search_pages search],
  duplicated: %i[dupped_search_oozes dupped_search_pages duplicated],
  retrieved:  %i[retrieved_oozes retrieved_pages retrieved],
  updated:    %i[updated_oozes updated_pages updated],
  created:    %i[created_oozes created_pages created],
  skipped:    %i[skipped_pages skipped],
  failed:     %i[failed_update_oozes failed_pages failed]
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, kpis: {}, updates: {}) ⇒ RunResult

Returns a new instance of RunResult.

Parameters:

  • label (String)

    human tag for this side ('legacy' / 'native').

  • kpis (Hash) (defaults to: {})

    KPI counters. Keys are symbolised; values coerced to Integer.

  • updates (Hash{String=>Object}) (defaults to: {})

    page_id => update payload (any Hash-ish).



24
25
26
27
28
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 24

def initialize(label:, kpis: {}, updates: {})
  @label   = label.to_s
  @kpis    = normalize_kpis(kpis)
  @updates = normalize_updates(updates)
end

Instance Attribute Details

#kpisObject (readonly)

Returns the value of attribute kpis.



19
20
21
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 19

def kpis
  @kpis
end

#labelObject (readonly)

Returns the value of attribute label.



19
20
21
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 19

def label
  @label
end

#updatesObject (readonly)

Returns the value of attribute updates.



19
20
21
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 19

def updates
  @updates
end

Instance Method Details

#compare_to(other) ⇒ Object

Compare against another RunResult, returning a Comparison value object.



36
37
38
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 36

def compare_to(other)
  Comparison.new(self, other)
end

#equivalent_to?(other) ⇒ Boolean

Convenience: are the two runs equivalent?

Returns:

  • (Boolean)


41
42
43
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 41

def equivalent_to?(other)
  compare_to(other).equivalent?
end

#page_idsObject

The set of page ids this run acted on.



31
32
33
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 31

def page_ids
  updates.keys
end

#to_hObject

Merge/normalise into a plain hash (handy for golden-file capture).



46
47
48
# File 'lib/eco/api/usecases/graphql/compat/parity/run_result.rb', line 46

def to_h
  { label: label, kpis: kpis, updates: updates }
end