Skip to content

Commit

Permalink
Merge pull request #2169 from ujh/ignored-pens-micro-clusters-page
Browse files Browse the repository at this point in the history
Page listing ignored pens micro clusters
  • Loading branch information
ujh authored Apr 25, 2024
2 parents b7048f2 + b83c1c2 commit 3c16027
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app/controllers/admins/pens/micro_clusters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ def index
end
end

def ignored
@clusters =
Pens::MicroCluster
.ignored
.joins(:collected_pens)
.select("pens_micro_clusters.*, count(*) as count")
.group("pens_micro_clusters.id")
.order(
"count desc, simplified_brand, simplified_model, simplified_color, simplified_material, simplified_trim_color, simplified_filling_system"
)
end

def update
cluster = Pens::MicroCluster.find(params[:id])
cluster.update!(update_params)
Expand Down
1 change: 1 addition & 0 deletions app/views/admins/micro_clusters/ignored.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ div class="fpc-table fpc-table--full-width fpc-scroll-shadow"
thead
tr
th ID
th Count
th Brand
th Line
th Name
Expand Down
23 changes: 23 additions & 0 deletions app/views/admins/pens/micro_clusters/ignored.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
div class="fpc-table fpc-table--full-width fpc-scroll-shadow"
table class="table align-middle table-striped"
thead
tr
th ID
th Count
th Brand
th Model
th Color
th Material
th Trim Color
th Filling System
tbody
- @clusters.each do |cluster|
tr
td= cluster.id
td= cluster.count
td= cluster.simplified_brand
td= cluster.simplified_model
td= cluster.simplified_color
td= cluster.simplified_material
td= cluster.simplified_trim_color
td= cluster.simplified_filling_system
1 change: 1 addition & 0 deletions app/views/layouts/admin/_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ nav class="fpc-header navbar navbar-dark navbar-expand-md" id="header"
a href="#" class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false" Pens
ul class="dropdown-menu"
li= link_to "Clustering app", admins_pens_micro_clusters_path, class: "dropdown-item"
li= link_to "Ignored Micro Clusters", ignored_admins_pens_micro_clusters_path, class: "dropdown-item"
li= link_to "Sidekiq", sidekiq_web_path, class: "nav-link"
li= link_to "Blog", admins_blog_posts_path, class: "nav-link"
li class="dropdown"
Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@
end

namespace :pens do
resources :micro_clusters, only: %i[index update]
resources :micro_clusters, only: %i[index update] do
collection { get "ignored" }
end
resources :model_variants, only: %i[index create show]
end

Expand Down

0 comments on commit 3c16027

Please sign in to comment.