lib/tobox/plugins/stats.rb in tobox-0.6.1 vs lib/tobox/plugins/stats.rb in tobox-0.7.0

- old
+ new

@@ -50,11 +50,18 @@ @inbox_ds = @db[inbox_table] end if @created_at_column # discard already handled events - @oldest_event_age_ds = @outbox_ds.where(last_error: nil, run_at: nil).order(Sequel.asc(:id)) + # + @oldest_event_age_ds = @outbox_ds.where(last_error: nil) + @oldest_event_age_ds = if config.visibility_type_bool? + @oldest_event_age_ds.where(config[:visibility_column] => false) + else + @oldest_event_age_ds.where(config[:visibility_column] => nil) + end + @oldest_event_age_ds = @oldest_event_age_ds.order(Sequel.asc(:id)) end logger = config.default_logger stats = method(:collect_event_stats) @@ -102,10 +109,10 @@ def collect_event_stats stats = @outbox_ds.group_and_count( Sequel.case([ [{ last_error: nil }, "pending_count"], - [Sequel.expr([:attempts]) < @max_attempts, "failing_count"] + [Sequel.expr(@config[:attempts_column]) < @max_attempts, "failing_count"] ], "failed_count").as(:status) ) stats = stats.as_hash(:status, :count).transform_keys(&:to_sym)