14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/queries/decidim/lausanne/budgets/metrics/budget_followers_metric_measure.rb', line 14
def calculate
budgets = Decidim::Lausanne::Budgets::LausanneBudget.where(component: @resource)
projects = Decidim::Lausanne::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(:loz_user_record_id)
budgets_followers = budgets_followers.where("decidim_follows.created_at >= ?", start_time)
quantity_users = budgets_followers.pluck(:loz_user_record_id)
{
cumulative_users: cumulative_users.uniq,
quantity_users: quantity_users.uniq
}
end
|