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
iv
gitlab-ce
Commits
6b9f221a
Commit
6b9f221a
authored
Nov 15, 2011
by
gitlabhq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perfomance fix
parent
76294699
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+3
-1
app/models/note.rb
app/models/note.rb
+2
-0
app/models/project.rb
app/models/project.rb
+11
-3
No files found.
app/controllers/issues_controller.rb
View file @
6b9f221a
...
@@ -19,6 +19,8 @@ class IssuesController < ApplicationController
...
@@ -19,6 +19,8 @@ class IssuesController < ApplicationController
else
@project
.
issues
.
opened
else
@project
.
issues
.
opened
end
end
@issues
=
@issues
.
includes
(
:author
,
:project
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# index.html.erb
format
.
html
# index.html.erb
format
.
js
format
.
js
...
@@ -35,7 +37,7 @@ class IssuesController < ApplicationController
...
@@ -35,7 +37,7 @@ class IssuesController < ApplicationController
end
end
def
show
def
show
@notes
=
@issue
.
notes
.
order
(
"created_at DESC"
).
limit
(
20
)
@notes
=
@issue
.
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
@note
=
@project
.
notes
.
new
(
:noteable
=>
@issue
)
@note
=
@project
.
notes
.
new
(
:noteable
=>
@issue
)
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/models/note.rb
View file @
6b9f221a
...
@@ -30,6 +30,8 @@ class Note < ActiveRecord::Base
...
@@ -30,6 +30,8 @@ class Note < ActiveRecord::Base
scope
:last_week
,
where
(
"created_at >= :date"
,
:date
=>
(
Date
.
today
-
7
.
days
))
scope
:last_week
,
where
(
"created_at >= :date"
,
:date
=>
(
Date
.
today
-
7
.
days
))
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
:date
=>
(
day
))
}
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
:date
=>
(
day
))
}
scope
:fresh
,
order
(
"created_at DESC"
)
scope
:fresh
,
order
(
"created_at DESC"
)
scope
:inc_author_project
,
includes
(
:project
,
:author
)
scope
:inc_author
,
includes
(
:author
)
mount_uploader
:attachment
,
AttachmentUploader
mount_uploader
:attachment
,
AttachmentUploader
end
end
...
...
app/models/project.rb
View file @
6b9f221a
...
@@ -74,8 +74,16 @@ class Project < ActiveRecord::Base
...
@@ -74,8 +74,16 @@ class Project < ActiveRecord::Base
users_projects
.
find_by_user_id
(
user
.
id
)
if
user
users_projects
.
find_by_user_id
(
user
.
id
)
if
user
end
end
def
fresh_issues
(
n
)
issues
.
includes
(
:project
,
:author
).
order
(
"created_at desc"
).
first
(
n
)
end
def
fresh_notes
(
n
)
notes
.
inc_author_project
.
order
(
"created_at desc"
).
first
(
n
)
end
def
common_notes
def
common_notes
notes
.
where
(
:noteable_type
=>
[
""
,
nil
])
notes
.
where
(
:noteable_type
=>
[
""
,
nil
])
.
inc_author_project
end
end
def
build_commit_note
(
commit
)
def
build_commit_note
(
commit
)
...
@@ -134,8 +142,8 @@ class Project < ActiveRecord::Base
...
@@ -134,8 +142,8 @@ class Project < ActiveRecord::Base
def
updates
(
n
=
3
)
def
updates
(
n
=
3
)
[
[
fresh_commits
(
n
),
fresh_commits
(
n
),
issues
.
last
(
n
),
fresh_issues
(
n
),
notes
.
fresh
.
limit
(
n
)
fresh_notes
(
n
)
].
compact
.
flatten
.
sort
do
|
x
,
y
|
].
compact
.
flatten
.
sort
do
|
x
,
y
|
y
.
created_at
<=>
x
.
created_at
y
.
created_at
<=>
x
.
created_at
end
[
0
...
n
]
end
[
0
...
n
]
...
...
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