Class: Athar::Dashboard::FeedQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/athar/dashboard/feed_query.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

DELETION_SEARCH_COLUMNS =
%w[
  record_type record_id::text schema_name table_name
  actor_type actor_id::text record_data::text metadata::text
].freeze
TABLE_EVENT_SEARCH_COLUMNS =
%w[
  schema_name table_name actor_type actor_id::text metadata::text
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(filters:, per_page: 25, now: Time.current, registry: nil) ⇒ FeedQuery

Returns a new instance of FeedQuery.



15
16
17
18
19
20
# File 'lib/athar/dashboard/feed_query.rb', line 15

def initialize(filters:, per_page: 25, now: Time.current, registry: nil)
  @filters = filters
  @per_page = per_page
  @now = now
  @registry = registry
end

Instance Method Details

#callObject



22
23
24
25
# File 'lib/athar/dashboard/feed_query.rb', line 22

def call
  audit_id_type # raise early on type mismatch instead of letting Postgres bubble a cryptic error
  connection.select_all(page_sql, "FeedQuery#call").map { |row| to_row(row) }
end

#totalObject



27
28
29
30
# File 'lib/athar/dashboard/feed_query.rb', line 27

def total
  audit_id_type
  connection.select_value(count_sql, "FeedQuery#total").to_i
end