Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
db723550
Commit
db723550
authored
Aug 23, 2016
by
Toby Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up usages of Mongoid to generate cleaner code / queries.
parent
925dd72a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
api/comment_threads.rb
+3
-2
presenters/thread_utils.rb
+2
-2
No files found.
api/comment_threads.rb
View file @
db723550
get
"
#{
APIPREFIX
}
/threads"
do
# retrieve threads by course
require
'new_relic/agent/method_tracer'
threads
=
Content
.
where
({
"_type"
=>
"CommentThread"
,
"course_id"
=>
params
[
"course_id"
]})
get
"
#{
APIPREFIX
}
/threads"
do
# retrieve threads by course
threads
=
CommentThread
.
where
({
"course_id"
=>
params
[
"course_id"
]})
if
params
[
:commentable_ids
]
if
params
[
:commentable_ids
]
threads
=
threads
.
in
({
"commentable_id"
=>
params
[
:commentable_ids
].
split
(
","
)})
threads
=
threads
.
in
({
"commentable_id"
=>
params
[
:commentable_ids
].
split
(
","
)})
end
end
...
...
presenters/thread_utils.rb
View file @
db723550
...
@@ -28,10 +28,10 @@ module ThreadUtils
...
@@ -28,10 +28,10 @@ module ThreadUtils
thread_key
=
t
.
_id
.
to_s
thread_key
=
t
.
_id
.
to_s
if
read_dates
.
has_key?
thread_key
if
read_dates
.
has_key?
thread_key
is_read
=
read_dates
[
thread_key
]
>=
t
.
updated_at
is_read
=
read_dates
[
thread_key
]
>=
t
.
updated_at
unread_comment_count
=
Comment
.
collection
.
find
(
unread_comment_count
=
Comment
.
where
(
:comment_thread_id
=>
t
.
_id
,
:comment_thread_id
=>
t
.
_id
,
:author_id
=>
{
"$ne"
=>
user
.
id
},
:author_id
=>
{
"$ne"
=>
user
.
id
},
:updated_at
=>
{
"$gte"
=>
read_dates
[
thread_key
]}
:updated_at
=>
{
"$gte"
=>
read_dates
[
thread_key
]}
,
).
count
).
count
read_states
[
thread_key
]
=
[
is_read
,
unread_comment_count
]
read_states
[
thread_key
]
=
[
is_read
,
unread_comment_count
]
end
end
...
...
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