Class: Dbwatcher::Storage::Api::TableAPI

Inherits:
BaseAPI
  • Object
show all
Defined in:
lib/dbwatcher/storage/api/table_api.rb

Instance Method Summary collapse

Methods inherited from BaseAPI

#create, #initialize, #limit, #where

Methods included from Concerns::DataNormalizer

#extract_value, #normalize_change, #normalize_hash_keys, #normalize_operation, #normalize_record_id, #normalize_session_data, #normalize_table_name, #normalize_timestamp

Constructor Details

This class inherits a constructor from Dbwatcher::Storage::Api::BaseAPI

Instance Method Details

#allArray<Hash>

Get all filtered changes

Returns:

  • (Array<Hash>)

    filtered changes



39
40
41
42
43
44
# File 'lib/dbwatcher/storage/api/table_api.rb', line 39

def all
  return [] unless @table_name

  changes = storage.load_changes(@table_name)
  apply_filters(changes)
end

#by_operation(operation) ⇒ TableAPI

Filter by operation type

Parameters:

  • operation (String, Symbol)

    operation type

Returns:

  • (TableAPI)

    self for method chaining



31
32
33
34
# File 'lib/dbwatcher/storage/api/table_api.rb', line 31

def by_operation(operation)
  filters[:operation] = normalize_operation(operation)
  self
end

#changes_for(table_name) ⇒ TableAPI

Filter changes for specific table

Parameters:

  • table_name (String)

    table name

Returns:

  • (TableAPI)

    self for method chaining



13
14
15
16
# File 'lib/dbwatcher/storage/api/table_api.rb', line 13

def changes_for(table_name)
  @table_name = table_name
  self
end

#most_active(limit: 10) ⇒ Array<Hash>

Get most active tables

Parameters:

  • limit (Integer) (defaults to: 10)

    maximum number of tables

Returns:

  • (Array<Hash>)

    most active tables



50
51
52
53
54
55
56
# File 'lib/dbwatcher/storage/api/table_api.rb', line 50

def most_active(limit: 10)
  # This would require aggregating across all tables
  # For now, return empty array - can be implemented later
  # TODO: Implement most active tables functionality with limit parameter
  _ = limit # Acknowledge the parameter for future use
  []
end

#recent(days: 7) ⇒ TableAPI

Filter to recent changes

Parameters:

  • days (Integer) (defaults to: 7)

    number of days back

Returns:

  • (TableAPI)

    self for method chaining



22
23
24
25
# File 'lib/dbwatcher/storage/api/table_api.rb', line 22

def recent(days: 7)
  filters[:recent_days] = days
  self
end