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