Commit 0ebc610e49b92d92e71aaea1ff664bcda121ff80
1 parent
ac620363
Exists in
master
and in
4 other branches
Project activities perfomance increased. Cache for project activitites disabled.…
… Repository conception changed
Showing
10 changed files
with
64 additions
and
4 deletions
Show diff stats
app/assets/stylesheets/projects.css.scss
... | ... | @@ -672,3 +672,17 @@ body.project-page h2.icon.loading { |
672 | 672 | } |
673 | 673 | } |
674 | 674 | } |
675 | + | |
676 | +a.project-update.titled { | |
677 | + position: relative; | |
678 | + padding-right: 310px !important; | |
679 | + | |
680 | + .right-block { | |
681 | + padding: 10px; | |
682 | + width: 280px; | |
683 | + background: #f5f5f5; | |
684 | + position: absolute; | |
685 | + right: 0; | |
686 | + top: 0; | |
687 | + } | |
688 | +} | ... | ... |
app/controllers/projects_controller.rb
... | ... | @@ -69,7 +69,7 @@ class ProjectsController < ApplicationController |
69 | 69 | def show |
70 | 70 | return render "projects/empty" unless @project.repo_exists? && @project.has_commits? |
71 | 71 | limit = (params[:limit] || 20).to_i |
72 | - @activities = @project.cached_updates(limit) | |
72 | + @activities = @project.updates_wo_repo(limit) | |
73 | 73 | end |
74 | 74 | |
75 | 75 | def files | ... | ... |
app/controllers/repositories_controller.rb
app/models/commit.rb
app/models/project.rb
... | ... | @@ -79,6 +79,7 @@ class Project < ActiveRecord::Base |
79 | 79 | :repo_exists?, |
80 | 80 | :commit, |
81 | 81 | :commits, |
82 | + :commits_with_refs, | |
82 | 83 | :tree, |
83 | 84 | :heads, |
84 | 85 | :commits_since, |
... | ... | @@ -144,6 +145,10 @@ class Project < ActiveRecord::Base |
144 | 145 | users_projects.find_by_user_id(user_id) |
145 | 146 | end |
146 | 147 | |
148 | + def fresh_merge_requests(n) | |
149 | + merge_requests.includes(:project, :author).order("created_at desc").first(n) | |
150 | + end | |
151 | + | |
147 | 152 | def fresh_issues(n) |
148 | 153 | issues.includes(:project, :author).order("created_at desc").first(n) |
149 | 154 | end |
... | ... | @@ -290,6 +295,16 @@ class Project < ActiveRecord::Base |
290 | 295 | end[0...n] |
291 | 296 | end |
292 | 297 | |
298 | + def updates_wo_repo(n=3) | |
299 | + [ | |
300 | + fresh_issues(n), | |
301 | + fresh_merge_requests(n), | |
302 | + fresh_notes(n) | |
303 | + ].compact.flatten.sort do |x, y| | |
304 | + y.created_at <=> x.created_at | |
305 | + end[0...n] | |
306 | + end | |
307 | + | |
293 | 308 | def check_limit |
294 | 309 | unless owner.can_create_project? |
295 | 310 | errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it") | ... | ... |
app/models/repository.rb
... | ... | @@ -112,6 +112,16 @@ class Repository |
112 | 112 | commits[0...n] |
113 | 113 | end |
114 | 114 | |
115 | + def commits_with_refs(n = 20) | |
116 | + commits = repo.refs.map { |ref| Commit.new(ref.commit, ref) } | |
117 | + | |
118 | + commits.sort! do |x, y| | |
119 | + y.committed_date <=> x.committed_date | |
120 | + end[0..n] | |
121 | + | |
122 | + commits | |
123 | + end | |
124 | + | |
115 | 125 | def commits_since(date) |
116 | 126 | commits = heads.map do |h| |
117 | 127 | repo.log(h.name, nil, :since => date).each { |c| Commit.new(c, h) } | ... | ... |
app/views/repositories/_head.html.haml
1 | 1 | .merge-tabs.repository |
2 | 2 | = link_to project_repository_path(@project), :class => "activities-tab tab #{'active' if current_page?(project_repository_path(@project)) }" do |
3 | 3 | %span |
4 | - Activities | |
4 | + History | |
5 | 5 | = link_to branches_project_repository_path(@project), :class => "tab #{'active' if current_page?(branches_project_repository_path(@project)) }" do |
6 | 6 | %span |
7 | 7 | Branches | ... | ... |
app/views/repositories/branches.html.haml
... | ... | @@ -6,5 +6,8 @@ |
6 | 6 | %a.update-item{:href => project_commits_path(@project, :ref => branch.name)} |
7 | 7 | %span.update-title{:style => "margin-bottom:0px;"} |
8 | 8 | = branch.name |
9 | + %span.update-author.right | |
10 | + = time_ago_in_words(branch.commit.committed_date) | |
11 | + ago | |
9 | 12 | - else |
10 | 13 | %h3 No brances | ... | ... |
app/views/repositories/show.html.haml
... | ... | @@ -4,4 +4,18 @@ |
4 | 4 | #news-feed.news-feed |
5 | 5 | .project-box.project-updates.ui-box.ui-box-small.ui-box-big |
6 | 6 | - @activities.each do |update| |
7 | - = render "projects/feed", :update => update, :project => @project | |
7 | + %a.project-update.titled{:href => project_commits_path(@project, :ref => update.head.name)} | |
8 | + = image_tag gravatar_icon(update.author_email), :class => "left", :width => 40 | |
9 | + %span.update-title | |
10 | + = dashboard_feed_title(update) | |
11 | + %span.update-author | |
12 | + %strong= update.author_name | |
13 | + authored | |
14 | + = time_ago_in_words(update.created_at) | |
15 | + ago | |
16 | + .right-block | |
17 | + %span.update-title | |
18 | + %span.commit.tag= update.head.name | |
19 | + %span.update-author | |
20 | + .right= truncate update.commit.id | |
21 | + | ... | ... |
app/views/repositories/tags.html.haml
... | ... | @@ -6,5 +6,8 @@ |
6 | 6 | %a.update-item{:href => project_commits_path(@project, :ref => tag.name)} |
7 | 7 | %span.update-title{:style => "margin-bottom:0px;"} |
8 | 8 | = tag.name |
9 | + %span.update-author.right | |
10 | + = time_ago_in_words(tag.commit.committed_date) | |
11 | + ago | |
9 | 12 | - else |
10 | 13 | %h3 No tags | ... | ... |