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
25eb96ad
Commit
25eb96ad
authored
Aug 13, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete invalid subscriptions & add id field for user to return
parent
77bfef7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
models/comment_thread.rb
+6
-0
models/user.rb
+2
-5
No files found.
models/comment_thread.rb
View file @
25eb96ad
...
@@ -55,6 +55,8 @@ class CommentThread < Content
...
@@ -55,6 +55,8 @@ class CommentThread < Content
before_create
:set_last_activity_at
before_create
:set_last_activity_at
before_update
:set_last_activity_at
before_update
:set_last_activity_at
before_destroy
:destroy_subscriptions
scope
:active_since
,
->
(
from_time
)
{
where
(
:last_activity_at
=>
{:
$gte
=>
from_time
})
}
scope
:active_since
,
->
(
from_time
)
{
where
(
:last_activity_at
=>
{:
$gte
=>
from_time
})
}
def
self
.
new_dumb_thread
(
options
=
{})
def
self
.
new_dumb_thread
(
options
=
{})
...
@@ -174,4 +176,8 @@ private
...
@@ -174,4 +176,8 @@ private
def
set_last_activity_at
def
set_last_activity_at
self
.
last_activity_at
=
Time
.
now
.
utc
unless
last_activity_at_changed?
self
.
last_activity_at
=
Time
.
now
.
utc
unless
last_activity_at_changed?
end
end
def
destroy_subscriptions
subscriptions
.
delete_all
end
end
end
models/user.rb
View file @
25eb96ad
...
@@ -53,17 +53,14 @@ class User
...
@@ -53,17 +53,14 @@ class User
subscribed_user_ids
.
map
{
|
id
|
User
.
find
(
id
)}
subscribed_user_ids
.
map
{
|
id
|
User
.
find
(
id
)}
end
end
def
to_hash
(
params
=
{})
def
to_hash
(
params
=
{})
hash
=
as_document
.
slice
(
*
%w[
_id
username external_id]
)
hash
=
as_document
.
slice
(
*
%w[username external_id]
)
if
params
[
:complete
]
if
params
[
:complete
]
hash
=
hash
.
merge
(
"subscribed_thread_ids"
=>
subscribed_thread_ids
,
hash
=
hash
.
merge
(
"subscribed_thread_ids"
=>
subscribed_thread_ids
,
"subscribed_commentable_ids"
=>
subscribed_commentable_ids
,
"subscribed_commentable_ids"
=>
subscribed_commentable_ids
,
"subscribed_user_ids"
=>
subscribed_user_ids
,
"subscribed_user_ids"
=>
subscribed_user_ids
,
"follower_ids"
=>
subscriptions_as_source
.
map
(
&
:subscriber_id
),
"follower_ids"
=>
subscriptions_as_source
.
map
(
&
:subscriber_id
),
"id"
=>
id
,
"upvoted_ids"
=>
upvoted_ids
,
"upvoted_ids"
=>
upvoted_ids
,
"downvoted_ids"
=>
downvoted_ids
)
"downvoted_ids"
=>
downvoted_ids
)
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