Sha256: b54fb5fb79abdd37697c67dfdca7de18b219d86fad88f662be2b55dc06deace4

Contents?: true

Size: 688 Bytes

Versions: 2

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true
module Thredded
  class Stats
    include ActionView::Helpers::NumberHelper

    class << self
      def messageboards_count
        new.messageboards_count
      end

      def topics_count
        new.topics_count
      end

      def posts_count
        new.posts_count
      end
    end

    def messageboards_count
      messageboards.count
    end

    def topics_count
      number_to_human(messageboards.map(&:topics_count).sum, precision: 4)
    end

    def posts_count
      number_to_human(messageboards.map(&:posts_count).sum, precision: 5)
    end

    private

    def messageboards
      @messageboards ||= Messageboard.all
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thredded-0.3.1 app/models/thredded/stats.rb
thredded-0.3.0 app/models/thredded/stats.rb