decidim-budgets/lib/decidim/budgets/feature.rb in decidim-0.0.8.1 vs decidim-budgets/lib/decidim/budgets/feature.rb in decidim-0.1.0
- old
+ new
@@ -17,9 +17,18 @@
feature.register_resource do |resource|
resource.model_class_name = "Decidim::Budgets::Project"
resource.template = "decidim/budgets/projects/linked_projects"
end
+ feature.register_stat :projects_count, primary: true do |features, start_at, end_at|
+ Decidim::Budgets::FilteredProjects.for(features, start_at, end_at).count
+ end
+
+ feature.register_stat :comments_count, tag: :comments do |features, start_at, end_at|
+ projects = Decidim::Budgets::FilteredProjects.for(features, start_at, end_at)
+ Decidim::Comments::Comment.where(root_commentable: projects).count
+ end
+
feature.settings(:global) do |settings|
settings.attribute :total_budget, type: :integer, default: 100_000_000
settings.attribute :vote_threshold_percent, type: :integer, default: 70
settings.attribute :comments_enabled, type: :boolean, default: true
end