Skip to content

Commit

Permalink
add external_service parameter to thread API
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Dec 21, 2017
1 parent 2d518f9 commit e69f05c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/api/route/thread_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ThreadApi < Base
optional :end_date, types: [DateTime, Date], desc: 'Only threads after or at the end date or time are returned'
optional :start_date, types: [DateTime, Date], desc: 'Only threads before or at the start date or time are returned'
optional :after_id, types: Integer, desc: 'Only threads with ID greather than this are returned'
optional :external_service, type: String, desc: 'Filter by external service short name'
end

helpers do
Expand All @@ -25,6 +26,7 @@ def post_or_get_thread
scope = scope.before_date(params[:end_date]) if params[:end_date]
scope = scope.after_date(params[:start_date]) if params[:start_date]
scope = scope.after_id(params[:after_id]) if params[:after_id]
scope = scope.joins(:external_service).where('external_services.short_name' => params[:external_service]) if params[:external_service]
scope = paginate scope
end
end
Expand Down

0 comments on commit e69f05c

Please sign in to comment.