Sha256: 5d6a4c2f246aebb0ebef75bed10eedb0385216168cee4c4b041e16b4a05f5435
Contents?: true
Size: 1.44 KB
Versions: 15
Compression:
Stored size: 1.44 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_key: "participatory_space_id", foreign_type: "participatory_space_type", polymorphic: true, optional: true belongs_to :related_object, foreign_key: "related_object_id", 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
15 entries across 15 versions & 1 rubygems