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
b860ebdb
Commit
b860ebdb
authored
Mar 13, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
candidate without inline
parent
790e719e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
4 deletions
+8
-4
app.rb
+2
-1
config/application.yml
+0
-1
lib/helpers.rb
+4
-2
models/comment_thread.rb
+2
-0
No files found.
app.rb
View file @
b860ebdb
...
@@ -45,7 +45,7 @@ APIPREFIX = CommentService::API_PREFIX
...
@@ -45,7 +45,7 @@ APIPREFIX = CommentService::API_PREFIX
DEFAULT_PAGE
=
1
DEFAULT_PAGE
=
1
DEFAULT_PER_PAGE
=
20
DEFAULT_PER_PAGE
=
20
if
RACK_ENV
.
to_s
!=
"
tes
t"
# disable api_key auth in test environment
if
RACK_ENV
.
to_s
!=
"
developmen
t"
# disable api_key auth in test environment
before
do
before
do
error
401
unless
params
[
:api_key
]
==
CommentService
.
config
[
:api_key
]
error
401
unless
params
[
:api_key
]
==
CommentService
.
config
[
:api_key
]
end
end
...
@@ -60,6 +60,7 @@ require './api/comment_threads'
...
@@ -60,6 +60,7 @@ require './api/comment_threads'
require
'./api/comments'
require
'./api/comments'
require
'./api/users'
require
'./api/users'
require
'./api/votes'
require
'./api/votes'
require
'./api/pins'
require
'./api/notifications_and_subscriptions'
require
'./api/notifications_and_subscriptions'
if
RACK_ENV
.
to_s
==
"development"
if
RACK_ENV
.
to_s
==
"development"
...
...
config/application.yml
View file @
b860ebdb
...
@@ -5,4 +5,3 @@ elasticsearch_server: <%= ENV['SEARCH_SERVER'] || 'http://localhost:9200' %>
...
@@ -5,4 +5,3 @@ elasticsearch_server: <%= ENV['SEARCH_SERVER'] || 'http://localhost:9200' %>
cache_timeout
:
cache_timeout
:
threads_search
:
10
threads_search
:
10
threads_query
:
10
threads_query
:
10
vote_juice_factor
:
10
#when a faculty votes (the request has juice) add this vote count to content's vote count
lib/helpers.rb
View file @
b860ebdb
...
@@ -107,7 +107,7 @@ helpers do
...
@@ -107,7 +107,7 @@ helpers do
end
end
sort_key_mapper
=
{
sort_key_mapper
=
{
"date"
=>
:created_at
,
"date"
=>
[
:created_at
]
,
"activity"
=>
:last_activity_at
,
"activity"
=>
:last_activity_at
,
"votes"
=>
:"votes.point"
,
"votes"
=>
:"votes.point"
,
"comments"
=>
:comment_count
,
"comments"
=>
:comment_count
,
...
@@ -127,7 +127,9 @@ helpers do
...
@@ -127,7 +127,9 @@ helpers do
else
else
page
=
(
params
[
"page"
]
||
DEFAULT_PAGE
).
to_i
page
=
(
params
[
"page"
]
||
DEFAULT_PAGE
).
to_i
per_page
=
(
params
[
"per_page"
]
||
DEFAULT_PER_PAGE
).
to_i
per_page
=
(
params
[
"per_page"
]
||
DEFAULT_PER_PAGE
).
to_i
comment_threads
=
comment_threads
.
order_by
(
"pinned DESC,
#{
sort_key
}
#{
sort_order
}
"
)
if
sort_key
&&
sort_order
#comment_threads = comment_threads.order_by("pinned DESC, #{sort_key} #{sort_order}") if sort_key && sort_order
#KChugh turns out we don't need to go through all the extra work on the back end because the client is resorting anyway
comment_threads
=
comment_threads
.
order_by
(
"
#{
sort_key
}
#{
sort_order
}
"
)
if
sort_key
&&
sort_order
num_pages
=
[
1
,
(
comment_threads
.
count
/
per_page
.
to_f
).
ceil
].
max
num_pages
=
[
1
,
(
comment_threads
.
count
/
per_page
.
to_f
).
ceil
].
max
page
=
[
num_pages
,
[
1
,
page
].
max
].
min
page
=
[
num_pages
,
[
1
,
page
].
max
].
min
paged_comment_threads
=
comment_threads
.
page
(
page
).
per
(
per_page
)
paged_comment_threads
=
comment_threads
.
page
(
page
).
per
(
per_page
)
...
...
models/comment_thread.rb
View file @
b860ebdb
...
@@ -45,6 +45,7 @@ class CommentThread < Content
...
@@ -45,6 +45,7 @@ class CommentThread < Content
indexes
:commentable_id
,
type: :string
,
index: :not_analyzed
,
included_in_all:
false
indexes
:commentable_id
,
type: :string
,
index: :not_analyzed
,
included_in_all:
false
indexes
:author_id
,
type: :string
,
as:
'author_id'
,
index: :not_analyzed
,
included_in_all:
false
indexes
:author_id
,
type: :string
,
as:
'author_id'
,
index: :not_analyzed
,
included_in_all:
false
indexes
:group_id
,
type: :integer
,
as:
'group_id'
,
index: :not_analyzed
,
included_in_all:
false
indexes
:group_id
,
type: :integer
,
as:
'group_id'
,
index: :not_analyzed
,
included_in_all:
false
#indexes :pinned, type: :boolean, as: 'pinned', index: :not_analyzed, included_in_all: false
end
end
belongs_to
:author
,
class_name:
"User"
,
inverse_of: :comment_threads
,
index:
true
#, autosave: true
belongs_to
:author
,
class_name:
"User"
,
inverse_of: :comment_threads
,
index:
true
#, autosave: true
...
@@ -177,6 +178,7 @@ class CommentThread < Content
...
@@ -177,6 +178,7 @@ class CommentThread < Content
"tags"
=>
tags_array
,
"tags"
=>
tags_array
,
"type"
=>
"thread"
,
"type"
=>
"thread"
,
"group_id"
=>
group_id
,
"group_id"
=>
group_id
,
"pinned"
=>
pinned?
,
"endorsed"
=>
endorsed?
)
"endorsed"
=>
endorsed?
)
if
params
[
:recursive
]
if
params
[
:recursive
]
...
...
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