Skip to content
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

Performance update on project index page #328

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ class ProjectsController < ApplicationController
before_action :set_team, only: [:index, :new, :create]

def index
@projects = @team.projects.select(:id, :name, :created_at, :updated_at)
@team_projects = @team.projects.select(:id, :source, :updated_at)
.order(Arel.sql("source->>'name'"))
.pluck(:id, Arel.sql("source->>'name'"), :updated_at)
.map { |id, name, updated_at| OpenStruct.new(id: id, name: name, updated_at: updated_at) }
render layout: "team"
end

Expand Down
10 changes: 5 additions & 5 deletions app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<div class="list-group-item list-group-item-light">
<input placeholder="Search" class="form-control" data-action="input->filter#update" autofocus>
</div>
<% @team.projects.sort_by { |project| project.name.downcase }.each do |project| %>
<% @team_projects.sort_by { |project| project.name.downcase }.each do |project| %>
<div class="list-group-item list-group-item-action p-0 align-items-center" data-filter-target="item" style="display: flex;">
<%= link_to project_path(project), class: "list-group-item list-group-item-action border-0" do %>
<%= link_to project_path(project.id), class: "list-group-item list-group-item-action border-0" do %>
<div class="d-flex align-items-center justify-content-between">
<div>
<%= project.name %>
Expand All @@ -23,13 +23,13 @@
<i class="fas fa-chevron-right"></i>
</div>
<% end %>
<%= link_to project_duplicates_path(project), method: :post, class: "px-3 py-2" do %>
<%= link_to project_duplicates_path(project.id), method: :post, class: "px-3 py-2" do %>
<i class="fas fa-clone"></i>
<% end %>
<%= link_to edit_project_path(project), class: "px-3 py-2" do %>
<%= link_to edit_project_path(project.id), class: "px-3 py-2" do %>
<i class="fas fa-edit"></i>
<% end %>
<%= link_to project_path(project), method: :delete, data: { confirm: "Are you sure you want to delete '#{project.name}'?" }, class: "px-3 py-2 text-danger" do %>
<%= link_to project_path(project.id), method: :delete, data: { confirm: "Are you sure you want to delete '#{project.name}'?" }, class: "px-3 py-2 text-danger" do %>
<i class="fas fa-trash-alt"></i>
<% end %>
</div>
Expand Down
Loading