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
5bf64eb0
Commit
5bf64eb0
authored
Sep 04, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make User model do more work in the DB layer
parent
9b188b87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
models/user.rb
+6
-6
No files found.
models/user.rb
View file @
5bf64eb0
...
@@ -31,23 +31,23 @@ class User
...
@@ -31,23 +31,23 @@ class User
end
end
def
subscribed_thread_ids
def
subscribed_thread_ids
subscriptions_as_subscriber
.
where
(
source_type:
"CommentThread"
).
map
(
&
:source_id
)
subscriptions_as_subscriber
.
where
(
source_type:
"CommentThread"
).
only
(
:source_id
).
map
(
&
:source_id
)
end
end
def
subscribed_commentable_ids
def
subscribed_commentable_ids
subscriptions_as_subscriber
.
where
(
source_type:
"Commentable"
).
map
(
&
:source_id
)
subscriptions_as_subscriber
.
where
(
source_type:
"Commentable"
).
only
(
:source_id
).
map
(
&
:source_id
)
end
end
def
subscribed_user_ids
def
subscribed_user_ids
subscriptions_as_subscriber
.
where
(
source_type:
"User"
).
map
(
&
:source_id
)
subscriptions_as_subscriber
.
where
(
source_type:
"User"
).
only
(
:source_id
).
map
(
&
:source_id
)
end
end
def
subscribed_threads
def
subscribed_threads
subscribed_thread_ids
.
map
{
|
id
|
CommentThread
.
find
(
id
)}
CommentThread
.
where
(
:id
.
in
=>
subscribed_thread_ids
).
without
(
:body
)
end
end
def
subscribed_commentables
def
subscribed_commentables
subscribed_commentable_ids
.
map
{
|
id
|
Commentable
.
find
(
id
)}
Commentable
.
where
(
:id
.
in
=>
subscribed_commentable_ids
).
only
(
:id
).
map
(
&
:id
)
end
end
def
subscribed_users
def
subscribed_users
...
@@ -60,7 +60,7 @@ class User
...
@@ -60,7 +60,7 @@ class User
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
.
only
(
:subscriber_id
).
map
(
&
:subscriber_id
),
"id"
=>
id
,
"id"
=>
id
,
"upvoted_ids"
=>
upvoted_ids
,
"upvoted_ids"
=>
upvoted_ids
,
"downvoted_ids"
=>
downvoted_ids
,
"downvoted_ids"
=>
downvoted_ids
,
...
...
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