Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/abuse_reports_finder.rb')
-rw-r--r--app/finders/abuse_reports_finder.rb47
1 files changed, 18 insertions, 29 deletions
diff --git a/app/finders/abuse_reports_finder.rb b/app/finders/abuse_reports_finder.rb
index 43cebd16d92..ee14372fcd9 100644
--- a/app/finders/abuse_reports_finder.rb
+++ b/app/finders/abuse_reports_finder.rb
@@ -17,6 +17,8 @@ class AbuseReportsFinder
end
def execute
+ @reports = reports.with_labels if Feature.enabled?(:abuse_report_labels)
+
filter_reports
aggregate_reports
sort_reports
@@ -27,30 +29,16 @@ class AbuseReportsFinder
private
def filter_reports
- if Feature.disabled?(:abuse_reports_list)
- filter_by_user_id
- return
- end
-
filter_by_status
filter_by_user
filter_by_reporter
filter_by_category
end
- def filter_by_user_id
- return unless params[:user_id].present?
-
- @reports = @reports.by_user_id(params[:user_id])
- end
-
def filter_by_status
return unless params[:status].present?
- status = params[:status]
- status = STATUS_OPEN unless status.in?(AbuseReport.statuses.keys)
-
- case status
+ case status_filter
when 'open'
@reports = @reports.open
when 'closed'
@@ -92,11 +80,6 @@ class AbuseReportsFinder
end
def sort_reports
- if Feature.disabled?(:abuse_reports_list)
- @reports = @reports.with_order_id_desc
- return
- end
-
# let sub_query in aggregate_reports do the sorting if sorting by number of reports
return if sort_key.in?(SORT_BY_COUNT)
@@ -107,15 +90,6 @@ class AbuseReportsFinder
User.by_username(username).pick(:id)
end
- def status_open?
- return unless Feature.enabled?(:abuse_reports_list) && params[:status].present?
-
- status = params[:status]
- status = STATUS_OPEN unless status.in?(AbuseReport.statuses.keys)
-
- status == STATUS_OPEN
- end
-
def aggregate_reports
if status_open?
sort_by_count = sort_key.in?(SORT_BY_COUNT)
@@ -124,4 +98,19 @@ class AbuseReportsFinder
@reports
end
+
+ def status_filter
+ @status_filter ||=
+ if params[:status].in?(AbuseReport.statuses.keys)
+ params[:status]
+ else
+ STATUS_OPEN
+ end
+ end
+
+ def status_open?
+ return false if params[:status].blank?
+
+ status_filter == STATUS_OPEN
+ end
end