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
6ffec9a2
Commit
6ffec9a2
authored
Sep 13, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Note to load notes in the right order
parent
8b6dba74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
app/contexts/notes/load_context.rb
app/contexts/notes/load_context.rb
+12
-11
app/models/note.rb
app/models/note.rb
+1
-1
No files found.
app/contexts/notes/load_context.rb
View file @
6ffec9a2
...
...
@@ -8,24 +8,25 @@ module Notes
@notes
=
case
target_type
when
"commit"
then
project
.
commit_notes
(
project
.
commit
(
target_id
)).
fresh
.
limit
(
20
)
when
"snippet"
then
project
.
snippets
.
find
(
target_id
).
notes
when
"wall"
then
project
.
common_notes
.
order
(
"created_at DESC"
).
fresh
.
limit
(
50
)
when
"commit"
project
.
commit_notes
(
project
.
commit
(
target_id
)).
fresh
.
limit
(
20
)
when
"issue"
then
project
.
issues
.
find
(
target_id
).
notes
.
inc_author
.
order
(
"created_at DESC"
)
.
limit
(
20
)
project
.
issues
.
find
(
target_id
).
notes
.
inc_author
.
fresh
.
limit
(
20
)
when
"merge_request"
then
project
.
merge_requests
.
find
(
target_id
).
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
project
.
merge_requests
.
find
(
target_id
).
notes
.
inc_author
.
fresh
.
limit
(
20
)
when
"snippet"
project
.
snippets
.
find
(
target_id
).
notes
.
fresh
when
"wall"
# this is the only case, where the order is DESC
project
.
common_notes
.
order
(
"created_at DESC"
).
limit
(
50
)
when
"wiki"
then
project
.
wikis
.
reverse
.
map
{
|
w
|
w
.
notes
.
fresh
}.
flatten
[
0
..
20
]
project
.
wikis
.
reverse
.
map
{
|
w
|
w
.
notes
.
fresh
}.
flatten
[
0
..
20
]
end
@notes
=
if
last_id
@notes
.
where
(
"id
>
?"
,
last_id
)
@notes
.
where
(
"id
<
?"
,
last_id
)
elsif
first_id
@notes
.
where
(
"id
<
?"
,
first_id
)
@notes
.
where
(
"id
>
?"
,
first_id
)
else
@notes
end
...
...
app/models/note.rb
View file @
6ffec9a2
...
...
@@ -36,7 +36,7 @@ class Note < ActiveRecord::Base
scope
:today
,
where
(
"created_at >= :date"
,
date:
Date
.
today
)
scope
:last_week
,
where
(
"created_at >= :date"
,
date:
(
Date
.
today
-
7
.
days
))
scope
:since
,
lambda
{
|
day
|
where
(
"created_at >= :date"
,
date:
(
day
))
}
scope
:fresh
,
order
(
"created_at
DE
SC"
)
scope
:fresh
,
order
(
"created_at
A
SC"
)
scope
:inc_author_project
,
includes
(
:project
,
:author
)
scope
:inc_author
,
includes
(
:author
)
...
...
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