-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InfluxDB performance measuring showed that this view is a bottleneck on Package#show with a mean render time of ~ 280 ms (bootstrap) and 160 ms (bentoo). Therefore we introduce now collection caching. We also need to introduce timeago_tag jquery gem to be able to cache the table otherwise the timeago would be cached as well causing wrong results.
- Loading branch information
Showing
8 changed files
with
61 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<tr id="file-<%= valid_xml_id(file[:name]) %>"> | ||
<td> | ||
<% link_opts = { action: :view_file, project: project, package: package, filename: file[:name], expand: expand } | ||
unless @is_current_rev | ||
link_opts[:rev] = file[:srcmd5] | ||
end %> | ||
<%= link_to_if(file[:viewable], nbsp(file[:name]), link_opts) %> | ||
</td> | ||
<td><span class="hidden"><%= file[:size].rjust(10, '0') %></span><%= human_readable_fsize(file[:size]) %> | ||
</td> | ||
<td><span class="hidden"><%= file[:mtime] %></span><%= timeago_tag Time.at(file[:mtime].to_i) %> | ||
</td> | ||
<!-- limit download for anonymous user to avoid getting killed by crawlers --> | ||
<td><%= if !User.current.is_nobody? || file[:size].to_i < (4 * 1024 * 1024) | ||
link_to sprite_tag('page_white_put', title: 'Download File'), | ||
file_url(project.name, package.name, file[:name], file[:srcmd5]) | ||
end %> | ||
<% if removable_file?(file_name: file[:name], package: package) %> | ||
<% if User.current.can_modify? package %> | ||
<%= link_to sprite_tag('page_white_delete', title: 'Remove File'), {:action => :remove_file, :project => project.to_param, | ||
:package => package.to_param, :filename => file[:name]}, | ||
{data: {confirm: "Really remove file '#{file[:name]}'?"}, :method => :post} %> | ||
<% end %> | ||
<% end %> | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
- can_be_removed = removable_file?(file_name: file[:name], package: package) && User.current.can_modify?(package) | ||
%tr{ id: "file-#{valid_xml_id(file[:name])}" } | ||
%td.text-word-break-all | ||
- link_opts = { action: :view_file, project: project, package: package, filename: file[:name], expand: expand } | ||
- unless is_current_rev | ||
- link_opts[:rev] = file[:srcmd5] | ||
= link_to_if(file[:viewable], nbsp(file[:name]), link_opts) | ||
%td.text-nowrap | ||
%span.d-none= file[:size].rjust(10, '0') | ||
= human_readable_fsize(file[:size]) | ||
%td.text-nowrap | ||
= timeago_tag Time.at(file[:mtime].to_i) | ||
/ limit download for anonymous user to avoid getting killed by crawlers | ||
%td.text-center | ||
- if !User.current.is_nobody? || file[:size].to_i < 4.megabytes | ||
= link_to(file_url(project.name, package.name, file[:name], file[:srcmd5]), title: 'Download file') do | ||
%i.fas.fa-download.text-secondary | ||
- if can_be_removed | ||
= link_to('#', data: { toggle: 'modal', target: "#delete-file-modal-#{file_counter}" }, | ||
title: 'Delete file') do | ||
%i.fas.fa-times-circle.text-danger | ||
- if can_be_removed | ||
= render(partial: 'delete_file_dialog', | ||
locals: { project: project.to_param, package: package.to_param, filename: file[:name], file_id: file_counter }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters