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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
8ad1f8a4
Commit
8ad1f8a4
authored
Nov 27, 2011
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
activities page caching
parent
fb8f05ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+17
-0
config/environments/production.rb
config/environments/production.rb
+1
-1
No files found.
app/controllers/projects_controller.rb
View file @
8ad1f8a4
...
@@ -67,7 +67,7 @@ class ProjectsController < ApplicationController
...
@@ -67,7 +67,7 @@ class ProjectsController < ApplicationController
def
show
def
show
return
render
"projects/empty"
unless
@project
.
repo_exists?
return
render
"projects/empty"
unless
@project
.
repo_exists?
limit
=
(
params
[
:limit
]
||
20
).
to_i
limit
=
(
params
[
:limit
]
||
20
).
to_i
@activities
=
@project
.
updates
(
limit
)
@activities
=
@project
.
cached_
updates
(
limit
)
end
end
#
#
...
...
app/models/project.rb
View file @
8ad1f8a4
...
@@ -143,6 +143,23 @@ class Project < ActiveRecord::Base
...
@@ -143,6 +143,23 @@ class Project < ActiveRecord::Base
last_activity
.
try
(
:created_at
)
last_activity
.
try
(
:created_at
)
end
end
# Get project updates from cache
# or calculate.
def
cached_updates
(
limit
,
expire
=
2
.
minutes
)
activities_key
=
"project_
#{
id
}
_activities"
cached_activities
=
Rails
.
cache
.
read
(
activities_key
)
if
cached_activities
activities
=
cached_activities
else
activities
=
updates
(
limit
)
Rails
.
cache
.
write
(
activities_key
,
activities
,
:expires_in
=>
60
.
seconds
)
end
activities
end
# Get 20 events for project like
# commits, issues or notes
def
updates
(
n
=
3
)
def
updates
(
n
=
3
)
[
[
fresh_commits
(
n
),
fresh_commits
(
n
),
...
...
config/environments/production.rb
View file @
8ad1f8a4
...
@@ -37,7 +37,7 @@ Gitlab::Application.configure do
...
@@ -37,7 +37,7 @@ Gitlab::Application.configure do
# config.logger = SyslogLogger.new
# config.logger = SyslogLogger.new
# Use a different cache store in production
# Use a different cache store in production
# config.cache_store = :mem_cache
_store
config
.
cache_store
=
:memory
_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# config.action_controller.asset_host = "http://assets.example.com"
...
...
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