13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/queries/decidim/budgets/metrics/budget_followers_metric_measure.rb', line 13
def calculate
budgets = Decidim::Budgets::Budget.where(component: @resource)
projects = Decidim::Budgets::Project.where(budget: budgets)
budgets_followers = Decidim::Follow.where(followable: projects).joins(:user)
.where("decidim_follows.created_at <= ?", end_time)
cumulative_users = budgets_followers.pluck(:decidim_user_id)
budgets_followers = budgets_followers.where("decidim_follows.created_at >= ?", start_time)
quantity_users = budgets_followers.pluck(:decidim_user_id)
{
cumulative_users: cumulative_users.uniq,
quantity_users: quantity_users.uniq
}
end
|