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
07febd58
Commit
07febd58
authored
Jul 25, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add user info api; fix comparison bug
parent
31a04cee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
6 deletions
+38
-6
Rakefile
+30
-5
app.rb
+5
-0
lib/util.rb
+1
-0
models/comment.rb
+2
-1
No files found.
Rakefile
View file @
07febd58
...
...
@@ -174,16 +174,15 @@ namespace :db do
users
=
(
1
..
10
).
map
{
|
id
|
User
.
find_or_create_by
(
external_id:
id
.
to_s
)}
3
.
times
do
users
.
first
.
subscribe
(
users
.
sample
)
end
10
.
times
do
users
.
sample
.
subscribe
(
users
.
sample
)
end
generate_comments_for
(
"question_1"
)
generate_comments_for
(
"question_2"
)
generate_comments_for
(
"course_1"
)
generate_comments_for
(
"lecture_1"
)
generate_comments_for
(
"video_1"
)
generate_comments_for
(
"video_2"
)
generate_comments_for
(
"lab_1"
)
generate_comments_for
(
"lab_2"
)
...
...
@@ -231,6 +230,32 @@ namespace :sunspot do
puts
"Successfully stopped Solr ..."
end
desc
'Restart the Solr instance'
task
:restart
=>
:environment
do
case
RUBY_PLATFORM
when
/w(in)?32$/
,
/java$/
abort
(
"This command is not supported on
#{
RUBY_PLATFORM
}
. "
+
"Use rake sunspot:solr:run to run Solr in the foreground."
)
end
Sunspot
::
Solr
::
Server
.
new
.
stop
Sunspot
::
Solr
::
Server
.
new
.
start
puts
"Successfully restarted Solr ..."
end
end
end
namespace
:jobs
do
desc
"Clear the delayed_job queue."
task
:clear
=>
:environment
do
Delayed
::
Job
.
delete_all
end
desc
"Start a delayed_job worker."
task
:work
=>
:environment
do
Delayed
::
Worker
.
new
(
:min_priority
=>
ENV
[
'MIN_PRIORITY'
],
:max_priority
=>
ENV
[
'MAX_PRIORITY'
],
:queues
=>
(
ENV
[
'QUEUES'
]
||
ENV
[
'QUEUE'
]
||
''
).
split
(
','
),
:quiet
=>
false
).
start
end
end
app.rb
View file @
07febd58
...
...
@@ -115,6 +115,11 @@ delete '/api/v1/threads/:thread_id/votes' do |thread_id|
undo_vote_for
thread
end
get
'/api/v1/users/:user_id'
do
|
user_id
|
user
=
User
.
find_or_create_by
(
external_id:
user_id
)
user
.
to_hash
(
complete:
params
[
"complete"
]).
to_json
end
get
'/api/v1/users/:user_id/notifications'
do
|
user_id
|
user
=
User
.
find_or_create_by
(
external_id:
user_id
)
user
.
notifications
.
map
(
&
:to_hash
).
to_json
...
...
lib/util.rb
View file @
07febd58
...
...
@@ -2,6 +2,7 @@ class NilClass
def
to_hash
{}
end
def
destroy
end
end
models/comment.rb
View file @
07febd58
...
...
@@ -30,7 +30,7 @@ class Comment < Content
def
to_hash
(
params
=
{})
sort_by_parent_and_time
=
Proc
.
new
do
|
x
,
y
|
arr_cmp
=
x
.
parent_ids
<=>
y
.
parent_ids
arr_cmp
=
x
.
parent_ids
.
map
(
&
:to_s
)
<=>
y
.
parent_ids
.
map
(
&
:to_s
)
if
arr_cmp
!=
0
arr_cmp
else
...
...
@@ -57,6 +57,7 @@ private
thread_id:
comment_thread
.
id
,
thread_title:
comment_thread
.
title
,
comment_id:
id
,
commentable_id:
comment_thread
.
commentable_id
,
},
)
notification
.
actor
=
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