Sha256: 1010b15bcb6380576126bf17203c3155a14e3923cc0ac8cc4b91b34dd7906b79

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module FileAuthorizationHandler
    # Provides information about the current status of the census data
    # for a given organization
    class Status
      def initialize(organization)
        @organization = organization
      end

      # Returns the date of the last import
      def last_import_at
        @last ||= CensusDatum.inside(@organization)
                             .order(created_at: :desc).first
        @last ? @last.created_at : nil
      end

      # Returns the number of unique census
      def count
        @count ||= CensusDatum.inside(@organization)
                              .distinct.count(:id_document)
        @count
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-file_authorization_handler-0.27.1.7 app/models/decidim/file_authorization_handler/status.rb
decidim-file_authorization_handler-0.27.1.6 app/models/decidim/file_authorization_handler/status.rb
decidim-file_authorization_handler-0.27.1.5 app/models/decidim/file_authorization_handler/status.rb