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
0060851a
Commit
0060851a
authored
Aug 21, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add shared key authentication
parent
3b10ee3f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
5 deletions
+7
-5
app.rb
+6
-0
config/application.yml
+1
-0
lib/helpers.rb
+0
-3
models/comment_thread.rb
+0
-2
No files found.
app.rb
View file @
0060851a
...
...
@@ -35,6 +35,12 @@ APIPREFIX = CommentService::API_PREFIX
DEFAULT_PAGE
=
1
DEFAULT_PER_PAGE
=
20
if
RACK_ENV
.
to_s
!=
"test"
# disable api_key auth in test environment
before
do
error
401
unless
params
[
:api_key
]
==
CommentService
.
config
[
:api_key
]
end
end
# these files must be required in order
require
'./api/search'
...
...
config/application.yml
View file @
0060851a
level_limit
:
3
cache_enabled
:
false
api_key
:
"
PUT_YOUR_API_KEY_HERE"
cache_timeout
:
threads_search
:
10
threads_query
:
10
lib/helpers.rb
View file @
0060851a
...
...
@@ -74,7 +74,6 @@ helpers do
memcached_key
=
"threads_query_
#{
query_params
.
hash
}
"
cached_results
=
Sinatra
::
Application
.
cache
.
get
(
memcached_key
)
if
cached_results
puts
"cache hit"
return
{
collection:
cached_results
[
:collection_ids
].
map
{
|
id
|
CommentThread
.
find
(
id
).
to_hash
(
recursive:
bool_recursive
)},
num_pages:
cached_results
[
:num_pages
],
...
...
@@ -83,8 +82,6 @@ helpers do
end
end
puts
"cache miss"
sort_key_mapper
=
{
"date"
=>
:created_at
,
"activity"
=>
:last_activity_at
,
...
...
models/comment_thread.rb
View file @
0060851a
...
...
@@ -94,10 +94,8 @@ class CommentThread < Content
memcached_key
=
"threads_search_
#{
params
.
merge
(
options
).
hash
}
"
results
=
Sinatra
::
Application
.
cache
.
get
(
memcached_key
)
if
results
puts
"cache hit"
return
results
end
puts
"cache miss"
end
search
=
Tire
::
Search
::
Search
.
new
'comment_threads'
search
.
query
{
|
query
|
query
.
text
:_all
,
params
[
"text"
]}
if
params
[
"text"
]
...
...
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