Skip to content

Commit

Permalink
Add activity_stream_csat_feedback endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dbt-gs committed Jan 10, 2025
1 parent 9e82b56 commit 18b2de3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/controllers/api/activity_stream_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,27 @@ def opportunities
respond_200 contents
end

def csat_feedback
check_auth && return

search_after = params.fetch(:search_after, '0.000000_0')
search_after_time_str, search_after_id_str = search_after.split('_')
search_after_time = Float(search_after_time_str)
search_after_id = Integer(search_after_id_str)

csat_feedback = CustomerSatisfactionFeedback.all

contents = to_activity_collection(csat_feedback).merge(
if csat_feedback.empty?
{}
else
{ next: "#{request.base_url}#{request.env['PATH_INFO']}?search_after=#{to_search_after(csat_feedback[-1], :updated_at)}" }
end
)

respond_200 contents
end

private

def check_auth
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
controller: 'api/activity_stream', format: 'json', via: [:get], as: :activity_stream_enquiries
get '/api/activity_stream/opportunities', action: :opportunities,
controller: 'api/activity_stream', format: 'json', via: [:get], as: :activity_stream_opportunities
get '/api/activity_stream/csat_feedback', action: :csat_feedback,
controller: 'api/activity_stream', format: 'json', via: [:get], as: :activity_stream_csat_feedback

post '/api/document/', action: :create, controller: 'api/document'

match '*path', to: 'errors#not_found', via: %i[get post patch put delete]
Expand Down

0 comments on commit 18b2de3

Please sign in to comment.