-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
193783b
commit 9c52943
Showing
9 changed files
with
63 additions
and
24 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
module API | ||
class PostsAPI < API::Base | ||
get '/' do | ||
std_result Post.all.order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
end | ||
|
||
params do | ||
requires :key, type: String | ||
requires :from, type: DateTime | ||
requires :to, type: DateTime | ||
end | ||
get 'date_range' do | ||
std_result Post.where('created_at > ?', params[:from]).where('created_at < ?', params[:to]).order(id: :desc), | ||
filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ' | ||
end | ||
|
||
params do | ||
requires :key, type: String | ||
requires :site, type: String | ||
end | ||
get 'on_site' do | ||
std_result Post.joins(:site).where(site: { site_domain: params[:site] }).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ' | ||
end | ||
|
||
params do | ||
requires :key, type: String | ||
requires :urls, type: String | ||
end | ||
get 'urls' do | ||
std_result Post.where(post_link: params[:urls].split(';')).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ' | ||
end | ||
|
||
params do | ||
requires :key, type: String | ||
requires :type, type: String | ||
end | ||
get 'with_feedback' do | ||
std_result Post.joins(:feedbacks).where(feedbacks: { feedback_type: params[:type] }).order(id: :desc), | ||
filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ' | ||
end | ||
|
||
get 'active' do | ||
std_result Post.where(deleted_at: nil).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ' | ||
end | ||
|
||
get 'ids/:ids' do | ||
std_result Post.where(id: params[:ids].split(';')).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ' | ||
end | ||
end | ||
end |
Could you extract these filters to a class variable of some sort in case they need to change later?