Commit c94159ab authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

improved dashboard

parent 219ac189
...@@ -615,6 +615,7 @@ p.time { ...@@ -615,6 +615,7 @@ p.time {
margin:auto; margin:auto;
.wll { .wll {
padding:5px;
border:none; border:none;
&:hover { &:hover {
background:none; background:none;
...@@ -623,12 +624,19 @@ p.time { ...@@ -623,12 +624,19 @@ p.time {
h4 { h4 {
color:#666; color:#666;
} }
&.event_feed {
min-height:40px;
border-bottom:1px solid #eee;
.avatar {
width:32px;
} }
}
}
.event_feed {
ul { ul {
margin-left:50px; margin-left:50px;
.avatar {
width:24px;
}
}
}
}
} }
} }
...@@ -4,12 +4,12 @@ class DashboardController < ApplicationController ...@@ -4,12 +4,12 @@ class DashboardController < ApplicationController
def index def index
@projects = current_user.projects.all @projects = current_user.projects.all
@active_projects = @projects.select(&:repo_exists?).select(&:last_activity_date_cached).sort_by(&:last_activity_date_cached).reverse @active_projects = @projects.select(&:last_activity_date).sort_by(&:last_activity_date).reverse
@merge_requests = MergeRequest.where("author_id = :id or assignee_id = :id", :id => current_user.id).opened.order("created_at DESC").limit(10) @merge_requests = MergeRequest.where("author_id = :id or assignee_id = :id", :id => current_user.id).opened.order("created_at DESC").limit(5)
@user = current_user @user = current_user
@issues = current_user.assigned_issues.opened.order("created_at DESC").limit(10) @issues = current_user.assigned_issues.opened.order("created_at DESC").limit(5)
@issues = @issues.includes(:author, :project) @issues = @issues.includes(:author, :project)
@events = Event.where(:project_id => @projects.map(&:id)).recent.limit(20) @events = Event.where(:project_id => @projects.map(&:id)).recent.limit(20)
......
...@@ -277,31 +277,21 @@ class Project < ActiveRecord::Base ...@@ -277,31 +277,21 @@ class Project < ActiveRecord::Base
end end
def last_activity def last_activity
updates(1).first events.last
rescue rescue
nil nil
end end
def last_activity_date def last_activity_date
last_activity.try(:created_at) if events.last
end events.last.created_at
def last_activity_date_cached(expire = 1.hour)
activity_date_key = "project_#{id}_activity_date"
cached_activities = Rails.cache.read(activity_date_key)
if cached_activities
activity_date = if cached_activities == "Never"
nil
else else
cached_activities updated_at
end end
else
activity_date = last_activity_date
Rails.cache.write(activity_date_key, activity_date || "Never", :expires_in => expire)
end end
activity_date def last_activity_date_cached(expire = 1.hour)
last_activity_date
end end
# Get project updates from cache # Get project updates from cache
......
- @events.each do |event| = render @events
.wll.event_feed
- if event.push?
- if event.new_branch?
User pushed new branch
- else
= image_tag gravatar_icon(event.pusher_email), :class => "avatar"
#{event.pusher_name} pushed to
= link_to project_commits_path(event.project, :ref => event.branch_name) do
%strong= event.branch_name
%span.cgray
= time_ago_in_words(event.created_at)
ago.
- if event.commits.count > 1
= link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]}
- @project = event.project
%ul.unstyled
= render event.commits
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
%div.dashboard_category %div.dashboard_category
%h3 %h3
Projects = link_to "Projects" , "#projects", :id => "projects"
%small %small
( most recent ) ( most recent )
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
- unless @merge_requests.blank? - unless @merge_requests.blank?
%div.dashboard_category %div.dashboard_category
%h3 %h3
Merge Requests = link_to "Merge Requests" , "#merge_requests", :id => "merge_requests"
%small ( authored or assigned to you ) %small ( authored or assigned to you )
%strong.right %strong.right
= link_to dashboard_merge_requests_path do = link_to dashboard_merge_requests_path do
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
- unless @issues.blank? - unless @issues.blank?
%div.dashboard_category %div.dashboard_category
%h3 %h3
Issues = link_to "Issues" , "#issues", :id => "issues"
%small ( assigned to you ) %small ( assigned to you )
%strong.right %strong.right
= link_to dashboard_merge_requests_path do = link_to dashboard_merge_requests_path do
...@@ -58,7 +59,7 @@ ...@@ -58,7 +59,7 @@
- unless @events.blank? - unless @events.blank?
%div.dashboard_category %div.dashboard_category
%h3 %h3
Activities = link_to "Activities" , "#activities", :id => "activities"
%hr %hr
.row .row
......
.wll.event_feed
- if event.push?
- if event.new_branch?
= image_tag gravatar_icon(event.pusher_email), :class => "avatar"
%strong #{event.pusher_name}
pushed new branch
= link_to project_commits_path(event.project, :ref => event.branch_name) do
%strong= event.branch_name
at
%strong= link_to event.project.name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.
- else
= image_tag gravatar_icon(event.pusher_email), :class => "avatar"
%strong #{event.pusher_name}
pushed to
= link_to project_commits_path(event.project, :ref => event.branch_name) do
%strong= event.branch_name
at
%strong= link_to event.project.name, event.project
%span.cgray
= time_ago_in_words(event.created_at)
ago.
- if event.commits.count > 1
= link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]}
- @project = event.project
%ul.unstyled
= render event.commits
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment