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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ac720275
Commit
ac720275
authored
Apr 01, 2022
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move queries to models
- Fix rubocop offences
parent
3eed8ffc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
11 deletions
+15
-11
app/mailers/emails/reviews.rb
app/mailers/emails/reviews.rb
+1
-8
app/models/discussion.rb
app/models/discussion.rb
+8
-0
app/models/review.rb
app/models/review.rb
+4
-0
app/views/notify/_note_email.html.haml
app/views/notify/_note_email.html.haml
+1
-1
app/views/notify/_note_email.text.erb
app/views/notify/_note_email.text.erb
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+0
-1
No files found.
app/mailers/emails/reviews.rb
View file @
ac720275
...
@@ -22,8 +22,7 @@ module Emails
...
@@ -22,8 +22,7 @@ module Emails
review
=
Review
.
find_by_id
(
review_id
)
review
=
Review
.
find_by_id
(
review_id
)
@notes
=
review
.
notes
@notes
=
review
.
notes
discussion_ids
=
@notes
.
pluck
(
:discussion_id
)
@discussions
=
Discussion
.
build_discussions
(
review
.
discussion_ids
,
preload_note_diff_file:
true
)
@discussions
=
discussions
(
discussion_ids
)
@author
=
review
.
author
@author
=
review
.
author
@author_name
=
review
.
author_name
@author_name
=
review
.
author_name
@project
=
review
.
project
@project
=
review
.
project
...
@@ -31,11 +30,5 @@ module Emails
...
@@ -31,11 +30,5 @@ module Emails
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
@sent_notification
=
SentNotification
.
record
(
@merge_request
,
recipient_id
,
reply_key
)
@sent_notification
=
SentNotification
.
record
(
@merge_request
,
recipient_id
,
reply_key
)
end
end
def
discussions
(
discussion_ids
)
notes
=
Note
.
where
(
discussion_id:
discussion_ids
).
inc_note_diff_file
.
fresh
grouped_notes
=
notes
.
group_by
{
|
n
|
n
.
discussion_id
}
grouped_notes
.
transform_values
{
|
notes
|
Discussion
.
build
(
notes
)
}
end
end
end
end
end
app/models/discussion.rb
View file @
ac720275
...
@@ -47,6 +47,14 @@ class Discussion
...
@@ -47,6 +47,14 @@ class Discussion
grouped_notes
.
values
.
map
{
|
notes
|
build
(
notes
,
context_noteable
)
}
grouped_notes
.
values
.
map
{
|
notes
|
build
(
notes
,
context_noteable
)
}
end
end
def
self
.
build_discussions
(
discussion_ids
,
context_noteable
=
nil
,
preload_note_diff_file:
false
)
notes
=
Note
.
where
(
discussion_id:
discussion_ids
).
fresh
notes
=
notes
.
inc_note_diff_file
if
preload_note_diff_file
grouped_notes
=
notes
.
group_by
{
|
n
|
n
.
discussion_id
}
grouped_notes
.
transform_values
{
|
notes
|
Discussion
.
build
(
notes
,
context_noteable
)
}
end
def
self
.
lazy_find
(
discussion_id
)
def
self
.
lazy_find
(
discussion_id
)
BatchLoader
.
for
(
discussion_id
).
batch
do
|
discussion_ids
,
loader
|
BatchLoader
.
for
(
discussion_id
).
batch
do
|
discussion_ids
,
loader
|
results
=
Note
.
where
(
discussion_id:
discussion_ids
).
fresh
.
to_a
.
group_by
(
&
:discussion_id
)
results
=
Note
.
where
(
discussion_id:
discussion_ids
).
fresh
.
to_a
.
group_by
(
&
:discussion_id
)
...
...
app/models/review.rb
View file @
ac720275
...
@@ -14,6 +14,10 @@ class Review < ApplicationRecord
...
@@ -14,6 +14,10 @@ class Review < ApplicationRecord
participant
:author
participant
:author
def
discussion_ids
notes
.
pluck
(
:discussion_id
)
end
def
all_references
(
current_user
=
nil
,
extractor:
nil
)
def
all_references
(
current_user
=
nil
,
extractor:
nil
)
ext
=
super
ext
=
super
...
...
app/views/notify/_note_email.html.haml
View file @
ac720275
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
-
note_style
=
local_assigns
.
fetch
(
:note_style
,
""
)
-
note_style
=
local_assigns
.
fetch
(
:note_style
,
""
)
-
skip_stylesheet_link
=
local_assigns
.
fetch
(
:skip_stylesheet_link
,
false
)
-
skip_stylesheet_link
=
local_assigns
.
fetch
(
:skip_stylesheet_link
,
false
)
-
discussion
=
local_assigns
.
fetch
(
:discussion
){
note
.
discussion
}
if
note
.
part_of_discussion?
-
discussion
=
local_assigns
.
fetch
(
:discussion
)
{
note
.
discussion
}
if
note
.
part_of_discussion?
%p
{
style:
"color: #777777;"
}
%p
{
style:
"color: #777777;"
}
=
succeed
':'
do
=
succeed
':'
do
...
...
app/views/notify/_note_email.text.erb
View file @
ac720275
<%
note
=
local_assigns
.
fetch
(
:note
,
@note
)
-%>
<%
note
=
local_assigns
.
fetch
(
:note
,
@note
)
-%>
<%
diff_limit
=
local_assigns
.
fetch
(
:diff_limit
,
nil
)
-%>
<%
diff_limit
=
local_assigns
.
fetch
(
:diff_limit
,
nil
)
-%>
<%
target_url
=
local_assigns
.
fetch
(
:target_url
,
@target_url
)
-%>
<%
target_url
=
local_assigns
.
fetch
(
:target_url
,
@target_url
)
-%>
<%
discussion
=
local_assigns
.
fetch
(
:discussion
){
note
.
discussion
}
if
note
.
part_of_discussion?
-%>
<%
discussion
=
local_assigns
.
fetch
(
:discussion
)
{
note
.
discussion
}
if
note
.
part_of_discussion?
-%>
<%=
sanitize_name
(
note
.
author_name
)
-%>
<%=
sanitize_name
(
note
.
author_name
)
-%>
<%
if
discussion
.
nil?
-%>
<%
if
discussion
.
nil?
-%>
...
...
spec/mailers/notify_spec.rb
View file @
ac720275
...
@@ -2182,7 +2182,6 @@ RSpec.describe Notify do
...
@@ -2182,7 +2182,6 @@ RSpec.describe Notify do
let!
(
:notes
)
{
create_list
(
:diff_note_on_merge_request
,
3
,
review:
review
,
project:
project
,
author:
review
.
author
,
noteable:
merge_request
)
}
let!
(
:notes
)
{
create_list
(
:diff_note_on_merge_request
,
3
,
review:
review
,
project:
project
,
author:
review
.
author
,
noteable:
merge_request
)
}
it
'links to notes and discussions'
,
:aggregate_failures
do
it
'links to notes and discussions'
,
:aggregate_failures
do
reply_note
=
create
(
:diff_note_on_merge_request
,
review:
review
,
project:
project
,
author:
review
.
author
,
noteable:
merge_request
,
in_reply_to:
notes
.
first
)
reply_note
=
create
(
:diff_note_on_merge_request
,
review:
review
,
project:
project
,
author:
review
.
author
,
noteable:
merge_request
,
in_reply_to:
notes
.
first
)
review
.
notes
.
each
do
|
note
|
review
.
notes
.
each
do
|
note
|
...
...
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