Class: Decidim::Proposals::Metrics::ProposalsMetricManage
- Inherits:
-
MetricManage
- Object
- MetricManage
- Decidim::Proposals::Metrics::ProposalsMetricManage
show all
- Defined in:
- decidim-proposals/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb
Instance Method Summary
collapse
for, #initialize, #valid?
Instance Method Details
#metric_name ⇒ Object
7
8
9
|
# File 'decidim-proposals/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb', line 7
def metric_name
"proposals"
end
|
#save ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'decidim-proposals/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb', line 11
def save
cumulative.each do |key, cumulative_value|
next if cumulative_value.zero?
quantity_value = quantity[key] || 0
category_id, space_type, space_id = key
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
organization: @organization, decidim_category_id: category_id,
participatory_space_type: space_type, participatory_space_id: space_id)
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
record.save!
end
end
|