Follow-up from "Default to showing open reports when given status filter is invalid"
The following discussion from !114587 (merged) should be addressed:
-
@ahmed.hemdan started a discussion: suggestion (non-blocking): not a big issue, but I think we could rewrite this as follows, wdyt?
status = params[:status].in?(AbuseReport.statuses.keys) ? params[:status] : DEFAULT_STATUS_FILTER
Another option was to do something like:
- status = DEFAULT_STATUS_FILTER unless status.in?(AbuseReport.statuses.keys)
-
- case status
- when 'open'
- @reports = @reports.open
- when 'closed'
- @reports = @reports.closed
- end
+ @reports = params[:status] == "closed" ? @reports.closed : @reports.open
Edited by João Alexandre Cunha