app/controllers/federails/server/nodeinfo_controller.rb in federails-0.2.0 vs app/controllers/federails/server/nodeinfo_controller.rb in federails-0.3.0

- old
+ new

@@ -1,20 +1,26 @@ module Federails module Server - class NodeinfoController < ServerController + class NodeinfoController < Federails::ServerController def index + skip_authorization + render formats: [:nodeinfo] end def show # rubocop:todo Metrics/AbcSize + skip_authorization + @total = @active_halfyear = @active_month = 0 + @has_user_counts = false Federails::Configuration.entity_types.each_value do |config| - next unless config[:include_in_user_count] + next unless (method = config[:user_count_method]&.to_sym) + @has_user_counts = true model = config[:class] - @total += model.count - @active_month += model.where(created_at: ((30.days.ago)...Time.current)).count - @active_halfyear += model.where(created_at: ((180.days.ago)...Time.current)).count + @total += model.send(method, nil) + @active_month += model.send(method, ((30.days.ago)...Time.current)) + @active_halfyear += model.send(method, ((180.days.ago)...Time.current)) end render formats: [:nodeinfo] end end end