Class: Athar::Dashboard::FeedQuery
- Inherits:
-
Object
- Object
- Athar::Dashboard::FeedQuery
- Defined in:
- lib/athar/dashboard/feed_query.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DELETION_SEARCH_COLUMNS =
Typed empty SELECT used for either UNION leg when the kind filter excludes that leg. Column types must match the live SELECTs above so PostgreSQL can compose the UNION without coercion.
%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
- EMPTY_LEG_SELECT =
<<~SQL SELECT NULL::text AS kind, NULL::bigint AS id, NULL::text AS record_type, NULL::text AS record_id, NULL::text AS schema_name, NULL::text AS table_name, NULL::text AS actor_type, NULL::text AS actor_id, NULL::timestamptz AS occurred_at, NULL::jsonb AS record_data, NULL::jsonb AS metadata WHERE FALSE SQL
Instance Method Summary collapse
- #call(connection: ActiveRecord::Base.connection) ⇒ Object
-
#initialize(filters:, per_page: 25, now: Time.current, registry: nil) ⇒ FeedQuery
constructor
A new instance of FeedQuery.
- #total(connection: ActiveRecord::Base.connection) ⇒ Object
Constructor Details
#initialize(filters:, per_page: 25, now: Time.current, registry: nil) ⇒ FeedQuery
Returns a new instance of FeedQuery.
34 35 36 37 38 39 |
# File 'lib/athar/dashboard/feed_query.rb', line 34 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
#call(connection: ActiveRecord::Base.connection) ⇒ Object
41 42 43 |
# File 'lib/athar/dashboard/feed_query.rb', line 41 def call(connection: ActiveRecord::Base.connection) connection.select_all(page_sql, "FeedQuery#call").map { |row| to_row(row) } end |
#total(connection: ActiveRecord::Base.connection) ⇒ Object
45 46 47 |
# File 'lib/athar/dashboard/feed_query.rb', line 45 def total(connection: ActiveRecord::Base.connection) connection.select_value(count_sql, "FeedQuery#total").to_i end |