-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from andela-iamadi/search_enhance_contd
Search Interface
- Loading branch information
Showing
16 changed files
with
154 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
json.comments @comment, partial: 'comments/default', as: :data | ||
json.comments comments, partial: 'comments/default', as: :data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
json.(data, :id, :content, :votes_count, :created_at, :updated_at) | ||
json.partial! 'users/user', user: data.user | ||
json.user do | ||
json.partial! 'users/user', user: data.user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
json.extract! question, :id, :title, :content, :votes_count ,:answers_count, :comments_count, :views, :created_at, :updated_at | ||
json.partial! 'users/user', user: question.user | ||
json.user do | ||
json.partial! 'users/user', user: question.user | ||
end | ||
json.url question_url(question) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
json.extract! question, :id, :title, :content | ||
json.user do | ||
json.extract! question.user, :name, :email | ||
end | ||
json.url question_url(question.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
json.questions(@questions) do |question| | ||
json.partial! 'questions/search_result', question: question | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
json.partial! 'questions/question', question: @question | ||
json.partial! 'tags/tag', tags: @question.tags_to_a | ||
json.partial! 'answers/answer', answers: @question.answers | ||
# require 'pry' ; binding.pry | ||
json.partial! 'comments/comment', comments: @question.comments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
json.user user, :id, :name, :email, :points, :image | ||
json.extract! user, :id, :name, :email, :points, :image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
Rack::Timeout.timeout = 20 # seconds | ||
if Rails.env.production? | ||
Rack::Timeout.timeout = 20 # seconds | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ GET /questions/:id |question's id, auth_token in header| Returns the question wi | |
GET questions/top_questions | offset, limit ( both could be optional ), auth_token in header | Returns the questions matching the criteria for top questions or error message if any. | ||
PUT questions/:id| question's id, update information(title, description), auth_token in header | Returns the updated question and all the information concerning it or error message if any. | ||
DELETE questions/:id| question's id, auth_token in header | Returns a confirmation that the question has been deleted or error message if any. | ||
GET questions/search | `q` which has the value of the params to search | Returns an array of questions, with a few things stripped off, such as association counts etc | ||
|
||
## GET /questions/ | ||
Request | ||
|
@@ -22,10 +23,8 @@ Status: 200 | |
id: 1, | ||
title: "what is Andela?", | ||
user_id: 1, | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
tags: [ "operations", "Andela"], | ||
}, | ||
{ | ||
id: 2 | ||
title: "where is Amity?" | ||
|
@@ -316,3 +315,60 @@ Status: 403 | |
message: Error Message | ||
} | ||
``` | ||
|
||
|
||
## GET /questions/search | ||
Request | ||
```ruby | ||
GET /questions/search?q=search+params | ||
``` | ||
Response | ||
```ruby | ||
Status: 200 | ||
{ | ||
questions:[{ | ||
id: 1, | ||
title: "what is Andela?", | ||
content: "Andela has been said to be everything" | ||
user: { | ||
name: 'User Name', | ||
email: '[email protected]', | ||
}, | ||
tags: [ "operations", "Andela"], | ||
url: 'http://zhishi.com/questions/1', | ||
} | ||
{ | ||
id: 2 | ||
title: "where is Amity?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 3 | ||
title: "what is M55?" | ||
user_id: 4 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 4 | ||
title: "What is DevOps?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
{ | ||
id: 5 | ||
title: "What is month one all about?" | ||
user_id: 12 | ||
tags: [{ | ||
matches: [ "operations", "Andela"], | ||
}], | ||
} | ||
] | ||
} | ||
``` |