BigW Consortium Gitlab

Commit c94159ab by Dmitriy Zaporozhets

improved dashboard

parent 219ac189
......@@ -615,6 +615,7 @@ p.time {
margin:auto;
.wll {
padding:5px;
border:none;
&:hover {
background:none;
......@@ -623,12 +624,19 @@ p.time {
h4 {
color:#666;
}
&.event_feed {
min-height:40px;
border-bottom:1px solid #eee;
.avatar {
width:32px;
}
ul {
margin-left:50px;
.avatar {
width:24px;
}
}
}
}
}
}
.event_feed {
ul {
margin-left:50px;
}
}
......@@ -4,12 +4,12 @@ class DashboardController < ApplicationController
def index
@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
@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)
@events = Event.where(:project_id => @projects.map(&:id)).recent.limit(20)
......
......@@ -277,31 +277,21 @@ class Project < ActiveRecord::Base
end
def last_activity
updates(1).first
events.last
rescue
nil
end
def last_activity_date
last_activity.try(:created_at)
end
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
cached_activities
end
if events.last
events.last.created_at
else
activity_date = last_activity_date
Rails.cache.write(activity_date_key, activity_date || "Never", :expires_in => expire)
updated_at
end
end
activity_date
def last_activity_date_cached(expire = 1.hour)
last_activity_date
end
# Get project updates from cache
......
- @events.each do |event|
.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
= render @events
......@@ -8,7 +8,7 @@
%div.dashboard_category
%h3
Projects
= link_to "Projects" , "#projects", :id => "projects"
%small
( most recent )
......@@ -34,7 +34,8 @@
- unless @merge_requests.blank?
%div.dashboard_category
%h3
Merge Requests
= link_to "Merge Requests" , "#merge_requests", :id => "merge_requests"
%small ( authored or assigned to you )
%strong.right
= link_to dashboard_merge_requests_path do
......@@ -46,7 +47,7 @@
- unless @issues.blank?
%div.dashboard_category
%h3
Issues
= link_to "Issues" , "#issues", :id => "issues"
%small ( assigned to you )
%strong.right
= link_to dashboard_merge_requests_path do
......@@ -58,7 +59,7 @@
- unless @events.blank?
%div.dashboard_category
%h3
Activities
= link_to "Activities" , "#activities", :id => "activities"
%hr
.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