Class: Dbwatcher::Services::Analyzers::SessionDataProcessor
- Inherits:
-
BaseService
- Object
- BaseService
- Dbwatcher::Services::Analyzers::SessionDataProcessor
- Defined in:
- lib/dbwatcher/services/analyzers/session_data_processor.rb
Overview
Handles session data processing and change iteration
This service extracts and processes individual changes from session data, providing a clean interface for iterating over table changes.
Instance Method Summary collapse
-
#call ⇒ Hash
Process all changes in the session.
-
#extract_session_tables ⇒ Array<String>
Extract session tables that were modified.
-
#extract_table_name(change) ⇒ String?
Extract table name from change data.
-
#initialize(session) ⇒ SessionDataProcessor
constructor
Initialize with session.
-
#process_changes {|table_name, change, tables| ... } ⇒ Hash
Process changes with block.
Methods inherited from BaseService
Methods included from Logging
#debug_enabled?, #log_debug, #log_error, #log_info, #log_warn
Constructor Details
#initialize(session) ⇒ SessionDataProcessor
Initialize with session
20 21 22 23 |
# File 'lib/dbwatcher/services/analyzers/session_data_processor.rb', line 20 def initialize(session) @session = session super() end |
Instance Method Details
#call ⇒ Hash
Process all changes in the session
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dbwatcher/services/analyzers/session_data_processor.rb', line 28 def call log_service_start "Processing session changes", session_context start_time = Time.current tables = {} process_changes do |table_name, change, tables_ref| yield(table_name, change, tables_ref) if block_given? end log_service_completion(start_time, { tables_found: tables.keys.length }) tables end |
#extract_session_tables ⇒ Array<String>
Extract session tables that were modified
74 75 76 77 78 79 80 |
# File 'lib/dbwatcher/services/analyzers/session_data_processor.rb', line 74 def extract_session_tables return [] unless session&.changes session.changes.map do |change| extract_table_name(change) end.compact.uniq end |
#extract_table_name(change) ⇒ String?
Extract table name from change data
65 66 67 68 69 |
# File 'lib/dbwatcher/services/analyzers/session_data_processor.rb', line 65 def extract_table_name(change) return nil unless change.is_a?(Hash) change[:table_name] end |
#process_changes {|table_name, change, tables| ... } ⇒ Hash
Process changes with block
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dbwatcher/services/analyzers/session_data_processor.rb', line 46 def process_changes return {} unless session&.changes.respond_to?(:each) tables = {} session.changes.each do |change| table_name = extract_table_name(change) next unless table_name yield(table_name, change, tables) if block_given? end tables end |