Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
734d6fcd
Commit
734d6fcd
authored
Apr 03, 2013
by
Andrey Kumanyaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perfomance updating Project activity sort
parent
41bbbb6d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
7 deletions
+32
-7
app/models/project.rb
app/models/project.rb
+5
-6
app/observers/project_activity_cache_observer.rb
app/observers/project_activity_cache_observer.rb
+8
-0
config/application.rb
config/application.rb
+1
-0
db/migrate/20130403003950_add_last_activity_column_into_project.rb
...e/20130403003950_add_last_activity_column_into_project.rb
+15
-0
db/schema.rb
db/schema.rb
+3
-1
No files found.
app/models/project.rb
View file @
734d6fcd
...
@@ -29,7 +29,7 @@ class Project < ActiveRecord::Base
...
@@ -29,7 +29,7 @@ class Project < ActiveRecord::Base
attr_accessible
:name
,
:path
,
:description
,
:default_branch
,
:issues_tracker
,
attr_accessible
:name
,
:path
,
:description
,
:default_branch
,
:issues_tracker
,
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:snippets_enabled
,
:issues_tracker_id
,
:issues_enabled
,
:wall_enabled
,
:merge_requests_enabled
,
:snippets_enabled
,
:issues_tracker_id
,
:wiki_enabled
,
:public
,
:import_url
,
as:
[
:default
,
:admin
]
:wiki_enabled
,
:public
,
:import_url
,
:last_activity_at
,
as:
[
:default
,
:admin
]
attr_accessible
:namespace_id
,
:creator_id
,
as: :admin
attr_accessible
:namespace_id
,
:creator_id
,
as: :admin
...
@@ -92,12 +92,12 @@ class Project < ActiveRecord::Base
...
@@ -92,12 +92,12 @@ class Project < ActiveRecord::Base
scope
:in_team
,
->
(
team
)
{
where
(
"id IN (:ids)"
,
ids:
team
.
projects
.
map
(
&
:id
))
}
scope
:in_team
,
->
(
team
)
{
where
(
"id IN (:ids)"
,
ids:
team
.
projects
.
map
(
&
:id
))
}
scope
:in_namespace
,
->
(
namespace
)
{
where
(
namespace_id:
namespace
.
id
)
}
scope
:in_namespace
,
->
(
namespace
)
{
where
(
namespace_id:
namespace
.
id
)
}
scope
:in_group_namespace
,
->
{
joins
(
:group
)
}
scope
:in_group_namespace
,
->
{
joins
(
:group
)
}
scope
:sorted_by_activity
,
->
{
order
(
"
(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id)
DESC"
)
}
scope
:sorted_by_activity
,
->
{
order
(
"
last_activity_at
DESC"
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
scope
:public_only
,
->
{
where
(
public:
true
)
}
scope
:public_only
,
->
{
where
(
public:
true
)
}
enumerize
:issues_tracker
,
:in
=>
(
Gitlab
.
config
.
issues_tracker
.
keys
).
append
(
:gitlab
),
:default
=>
:gitlab
enumerize
:issues_tracker
,
in:
(
Gitlab
.
config
.
issues_tracker
.
keys
).
append
(
:gitlab
),
default:
:gitlab
class
<<
self
class
<<
self
def
abandoned
def
abandoned
...
@@ -157,8 +157,7 @@ class Project < ActiveRecord::Base
...
@@ -157,8 +157,7 @@ class Project < ActiveRecord::Base
unless
creator
.
can_create_project?
unless
creator
.
can_create_project?
errors
[
:limit_reached
]
<<
(
"Your own projects limit is
#{
creator
.
projects_limit
}
! Please contact administrator to increase it"
)
errors
[
:limit_reached
]
<<
(
"Your own projects limit is
#{
creator
.
projects_limit
}
! Please contact administrator to increase it"
)
end
end
rescue
=>
ex
rescue
errors
[
:base
]
<<
ex
.
message
errors
[
:base
]
<<
(
"Can't check your ability to create project"
)
errors
[
:base
]
<<
(
"Can't check your ability to create project"
)
end
end
...
@@ -191,7 +190,7 @@ class Project < ActiveRecord::Base
...
@@ -191,7 +190,7 @@ class Project < ActiveRecord::Base
end
end
def
last_activity_date
def
last_activity_date
last_
event
.
try
(
:created_at
)
||
updated
_at
last_
activity
_at
end
end
def
project_id
def
project_id
...
...
app/observers/project_activity_cache_observer.rb
0 → 100644
View file @
734d6fcd
class
ProjectActivityCacheObserver
<
BaseObserver
observe
:event
def
after_create
(
event
)
event
.
project
.
update_attribute
(
:last_activity_at
,
event
.
created_at
)
if
event
.
project
end
end
config/application.rb
View file @
734d6fcd
...
@@ -24,6 +24,7 @@ module Gitlab
...
@@ -24,6 +24,7 @@ module Gitlab
# Activate observers that should always be running.
# Activate observers that should always be running.
config
.
active_record
.
observers
=
:activity_observer
,
config
.
active_record
.
observers
=
:activity_observer
,
:project_activity_cache_observer
,
:issue_observer
,
:issue_observer
,
:key_observer
,
:key_observer
,
:merge_request_observer
,
:merge_request_observer
,
...
...
db/migrate/20130403003950_add_last_activity_column_into_project.rb
0 → 100644
View file @
734d6fcd
class
AddLastActivityColumnIntoProject
<
ActiveRecord
::
Migration
def
up
add_column
:projects
,
:last_activity_at
,
:datetime
add_index
:projects
,
:last_activity_at
Project
.
find_each
do
|
project
|
project
.
update_attribute
(
:last_activity_at
,
project
.
last_activity_date
)
end
end
def
down
remove_index
:projects
,
:last_activity_at
remove_column
:projects
,
:last_activity_at
end
end
db/schema.rb
View file @
734d6fcd
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
20130
325173941
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20130
403003950
)
do
create_table
"events"
,
:force
=>
true
do
|
t
|
create_table
"events"
,
:force
=>
true
do
|
t
|
t
.
string
"target_type"
t
.
string
"target_type"
...
@@ -156,9 +156,11 @@ ActiveRecord::Schema.define(:version => 20130325173941) do
...
@@ -156,9 +156,11 @@ ActiveRecord::Schema.define(:version => 20130325173941) do
t
.
string
"issues_tracker"
,
:default
=>
"gitlab"
,
:null
=>
false
t
.
string
"issues_tracker"
,
:default
=>
"gitlab"
,
:null
=>
false
t
.
string
"issues_tracker_id"
t
.
string
"issues_tracker_id"
t
.
boolean
"snippets_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
boolean
"snippets_enabled"
,
:default
=>
true
,
:null
=>
false
t
.
datetime
"last_activity_at"
end
end
add_index
"projects"
,
[
"creator_id"
],
:name
=>
"index_projects_on_owner_id"
add_index
"projects"
,
[
"creator_id"
],
:name
=>
"index_projects_on_owner_id"
add_index
"projects"
,
[
"last_activity_at"
],
:name
=>
"index_projects_on_last_activity_at"
add_index
"projects"
,
[
"namespace_id"
],
:name
=>
"index_projects_on_namespace_id"
add_index
"projects"
,
[
"namespace_id"
],
:name
=>
"index_projects_on_namespace_id"
create_table
"protected_branches"
,
:force
=>
true
do
|
t
|
create_table
"protected_branches"
,
:force
=>
true
do
|
t
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment