@@ -6,23 +6,30 @@ class Admin::Certification::ShipsController < Admin::Certification::ApplicationC
66 def index
77 authorize ::Certification ::Ship
88
9- @status = params [ :status ] . presence_in ( %w[ pending approved returned all ] ) || "pending"
10- @sort = params [ :sort ] == "newest" ? "newest" : "oldest"
11- @search = params [ :search ] . to_s . strip
12- @from = parse_date ( params [ :from ] )
13- @to = parse_date ( params [ :to ] )
9+ @status = params [ :status ] . presence_in ( %w[ pending approved returned all ] ) || "pending"
10+ @sort = params [ :sort ] == "newest" ? "newest" : "oldest"
11+ @search = params [ :search ] . to_s . strip
12+ @from = parse_date ( params [ :from ] )
13+ @to = parse_date ( params [ :to ] )
14+ @project_type = params [ :project_type ] . presence
1415
1516 scope = policy_scope ( ::Certification ::Ship )
16- . includes ( :reviewer , project : { memberships : :user } )
1717 scope = scope . where ( status : @status ) unless @status == "all"
1818 scope = scope . where ( "certification_ship_reviews.created_at >= ?" , @from . beginning_of_day ) if @from
1919 scope = scope . where ( "certification_ship_reviews.created_at <= ?" , @to . end_of_day ) if @to
2020 scope = apply_search ( scope ) if @search . present?
2121
22+ @type_counts = scope . joins ( :project ) . group ( "projects.project_type" ) . count
23+
24+ scope = scope . by_project_type ( @project_type ) if @project_type . present?
25+
2226 @pagy , @ships = pagy ( :offset ,
23- scope . order ( created_at : @sort == "newest" ? :desc : :asc ) ,
27+ scope . includes ( :reviewer , project : { memberships : :user } )
28+ . order ( created_at : @sort == "newest" ? :desc : :asc ) ,
2429 limit : 25 )
2530
31+ @own_project_ids = current_user . memberships . pluck ( :project_id ) . to_set
32+
2633 @stats = ::Certification ::Ship . dashboard_stats
2734 @lb_period = params [ :lb ] . presence_in ( %w[ daily weekly alltime ] ) || "daily"
2835 @leaderboards = {
0 commit comments