-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add advanced filters to admin budget investments #1956
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,7 +122,9 @@ def self.scoped_filter(params, current_filter) | |
results = Investment.by_budget(budget) | ||
|
||
results = results.where("cached_votes_up + physical_votes >= ?", | ||
params[:min_total_supports]) if params[:min_total_supports].present? | ||
params[:min_total_supports]) if params[:min_total_supports].present? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [114/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) |
||
results = results.where("cached_votes_up + physical_votes <= ?", | ||
params[:max_total_supports]) if params[:max_total_supports].present? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [114/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [114/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) |
||
results = results.where(group_id: params[:group_id]) if params[:group_id].present? | ||
results = results.by_tag(params[:tag_name]) if params[:tag_name].present? | ||
results = results.by_heading(params[:heading_id]) if params[:heading_id].present? | ||
|
@@ -137,12 +139,19 @@ def self.scoped_filter(params, current_filter) | |
end | ||
|
||
def self.advanced_filters(params, results) | ||
results = results.without_admin if params[:advanced_filters].include?("without_admin") | ||
results = results.without_valuator if params[:advanced_filters].include?("without_valuator") | ||
results = results.under_valuation if params[:advanced_filters].include?("under_valuation") | ||
results = results.valuation_finished if params[:advanced_filters].include?("valuation_finished") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [102/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) |
||
results = results.winners if params[:advanced_filters].include?("winners") | ||
|
||
ids = [] | ||
ids += results.valuation_finished_feasible.pluck(:id) if params[:advanced_filters].include?("feasible") | ||
ids += results.where(selected: true).pluck(:id) if params[:advanced_filters].include?("selected") | ||
ids += results.undecided.pluck(:id) if params[:advanced_filters].include?("undecided") | ||
ids += results.unfeasible.pluck(:id) if params[:advanced_filters].include?("unfeasible") | ||
results.where("budget_investments.id IN (?)", ids) | ||
results = results.where("budget_investments.id IN (?)", ids) if ids.any? | ||
results | ||
end | ||
|
||
def self.order_filter(params) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [114/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)