From 5eeea4b7c69d29e8e8371b3c63f25938dcca7bb6 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 4 Mar 2016 15:20:30 +0100 Subject: Limit the number of commits shown in MRs This prevents timeouts when creating a MR with 1000s of commits. --- app/views/projects/commits/_commits.html.haml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'app/views') diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml index 6c631228002..e708b2df540 100644 --- a/app/views/projects/commits/_commits.html.haml +++ b/app/views/projects/commits/_commits.html.haml @@ -1,7 +1,13 @@ - unless defined?(project) - project = @project +- if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + - commits = @commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE) + - overflow = true +- else + - commits = @commits + - overflow = false -- @commits.group_by { |c| c.committed_date.to_date }.sort.reverse.each do |day, commits| +- commits.group_by { |c| c.committed_date.to_date }.sort.reverse.each do |day, commits| .row.commits-row .col-md-2.hidden-xs.hidden-sm %h5.commits-row-date @@ -13,3 +19,7 @@ %ul.bordered-list = render commits, project: project %hr.lists-separator + +- if overflow + .alert.alert-warning + Not shown: #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} more commits -- cgit v1.2.1 From f943156b5e4cf5e00ea5373de55deb993c72662d Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 4 Mar 2016 15:45:58 +0100 Subject: Put 'hidden commits' logic in CommitsHelper --- app/views/projects/commits/_commit_list.html.haml | 11 +++++++---- app/views/projects/commits/_commits.html.haml | 12 ++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'app/views') diff --git a/app/views/projects/commits/_commit_list.html.haml b/app/views/projects/commits/_commit_list.html.haml index ce60fbdf032..5fe4d918833 100644 --- a/app/views/projects/commits/_commit_list.html.haml +++ b/app/views/projects/commits/_commit_list.html.haml @@ -1,11 +1,14 @@ +- commits, hidden = limited_commits(@commits, @project) +- commits = Commit.decorate(commits, @project) + %div.panel.panel-default .panel-heading Commits (#{@commits.count}) - - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + - if hidden > 0 %ul.well-list - - Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE), @project).each do |commit| + - commits.each do |commit| = render "projects/commits/inline_commit", commit: commit, project: @project %li.warning-row.unstyled - other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues. + other #{hidden} commits hidden to prevent performance issues. - else - %ul.well-list= render Commit.decorate(@commits, @project), project: @project + %ul.well-list= render commits, project: @project diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml index e708b2df540..998251094a4 100644 --- a/app/views/projects/commits/_commits.html.haml +++ b/app/views/projects/commits/_commits.html.haml @@ -1,11 +1,7 @@ - unless defined?(project) - project = @project -- if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE - - commits = @commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE) - - overflow = true -- else - - commits = @commits - - overflow = false + +- commits, hidden = limited_commits(@commits) - commits.group_by { |c| c.committed_date.to_date }.sort.reverse.each do |day, commits| .row.commits-row @@ -20,6 +16,6 @@ = render commits, project: project %hr.lists-separator -- if overflow +- if hidden > 0 .alert.alert-warning - Not shown: #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} more commits + Not shown: #{hidden} more commits -- cgit v1.2.1 From 823633325833a6449be9351cec7d78788274d57f Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 7 Mar 2016 10:41:49 +0100 Subject: Finish refactor --- app/views/projects/commits/_commit_list.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/views') diff --git a/app/views/projects/commits/_commit_list.html.haml b/app/views/projects/commits/_commit_list.html.haml index 5fe4d918833..62e5f346777 100644 --- a/app/views/projects/commits/_commit_list.html.haml +++ b/app/views/projects/commits/_commit_list.html.haml @@ -1,4 +1,4 @@ -- commits, hidden = limited_commits(@commits, @project) +- commits, hidden = limited_commits(@commits) - commits = Commit.decorate(commits, @project) %div.panel.panel-default -- cgit v1.2.1 From d51877cac821d17bd79c9c0efbd8e15b7f4c09a3 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 7 Mar 2016 10:42:27 +0100 Subject: Change "some commits hidden" message --- app/views/projects/commits/_commit_list.html.haml | 2 +- app/views/projects/commits/_commits.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/views') diff --git a/app/views/projects/commits/_commit_list.html.haml b/app/views/projects/commits/_commit_list.html.haml index 62e5f346777..c0988eca6de 100644 --- a/app/views/projects/commits/_commit_list.html.haml +++ b/app/views/projects/commits/_commit_list.html.haml @@ -9,6 +9,6 @@ - commits.each do |commit| = render "projects/commits/inline_commit", commit: commit, project: @project %li.warning-row.unstyled - other #{hidden} commits hidden to prevent performance issues. + #{number_with_delimiter(hidden)} additional commits have been omitted. - else %ul.well-list= render commits, project: @project diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml index 998251094a4..787fe443ac8 100644 --- a/app/views/projects/commits/_commits.html.haml +++ b/app/views/projects/commits/_commits.html.haml @@ -18,4 +18,4 @@ - if hidden > 0 .alert.alert-warning - Not shown: #{hidden} more commits + #{number_with_delimiter(hidden)} additional commits have been omitted. -- cgit v1.2.1 From 9d9d2fbbc23e030416a6ebab556e87cf7014a057 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 9 Mar 2016 12:00:17 +0100 Subject: Prevent performance issues --- app/views/projects/commits/_commit_list.html.haml | 2 +- app/views/projects/commits/_commits.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/views') diff --git a/app/views/projects/commits/_commit_list.html.haml b/app/views/projects/commits/_commit_list.html.haml index c0988eca6de..bac9e244d36 100644 --- a/app/views/projects/commits/_commit_list.html.haml +++ b/app/views/projects/commits/_commit_list.html.haml @@ -9,6 +9,6 @@ - commits.each do |commit| = render "projects/commits/inline_commit", commit: commit, project: @project %li.warning-row.unstyled - #{number_with_delimiter(hidden)} additional commits have been omitted. + #{number_with_delimiter(hidden)} additional commits have been omitted to prevent performance issues. - else %ul.well-list= render commits, project: @project diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml index 787fe443ac8..a7e3c2478c2 100644 --- a/app/views/projects/commits/_commits.html.haml +++ b/app/views/projects/commits/_commits.html.haml @@ -18,4 +18,4 @@ - if hidden > 0 .alert.alert-warning - #{number_with_delimiter(hidden)} additional commits have been omitted. + #{number_with_delimiter(hidden)} additional commits have been omitted to prevent performance issues. -- cgit v1.2.1