Sha256: a24fa12f625bd33634886eb02f5aef10bba7ef3e0d02b844af403cf40a5a7797

Contents?: true

Size: 1.37 KB

Versions: 50

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Decidim
  # A Metric is a registry that holds cumulative and quantity value by day, category, participatory_space, category, an a related object
  class Metric < ApplicationRecord
    # ParticipatorySpace, RelatedObject and Category are optional relationships because not all metric objects need them
    # For example, User is only related to an organization, but a Proposal can have all of them
    belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
    belongs_to :participatory_space, foreign_type: "participatory_space_type", polymorphic: true, optional: true
    belongs_to :related_object, foreign_type: "related_object_type", polymorphic: true, optional: true
    belongs_to :category, foreign_key: "decidim_category_id", class_name: "Decidim::Category", optional: true

    validates :day, uniqueness: { scope:
                                  [
                                    :metric_type,
                                    :decidim_organization_id,
                                    :participatory_space_type,
                                    :participatory_space_id,
                                    :related_object_type,
                                    :related_object_id,
                                    :decidim_category_id
                                  ] }
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
decidim-core-0.25.0.rc4 app/models/decidim/metric.rb
decidim-core-0.25.0.rc3 app/models/decidim/metric.rb
decidim-core-0.25.0.rc2 app/models/decidim/metric.rb
decidim-core-0.25.0.rc1 app/models/decidim/metric.rb
decidim-core-0.24.3 app/models/decidim/metric.rb
decidim-core-0.24.2 app/models/decidim/metric.rb
decidim-core-0.24.1 app/models/decidim/metric.rb
decidim-core-0.24.0 app/models/decidim/metric.rb
decidim-core-0.24.0.rc2 app/models/decidim/metric.rb
decidim-core-0.24.0.rc1 app/models/decidim/metric.rb