Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Fix next_page on Dashboard.recent and Stat.latest_for_teams #41

Merged
merged 3 commits into from
Oct 19, 2016

Conversation

johnathanludwig
Copy link
Contributor

@johnathanludwig johnathanludwig commented Oct 18, 2016

Calling next_page on Dashboard.recent or Stat.latest_for_teams would return a merge for nil error. This turned out to be because the pagination wasn't set up when calling find_every. After fixing that it was discovered that the PaginatedCollection uses where for next_page calls so that had to be enabled.

This also requires some server side changes due to where making a PUT request. PUT was not supported for these two endpoints previously.

I also discovered that next_page would cause a server side error on other APIs. This was because the logic in where that parses the page numbers was not always a symbol key, causing the page parameter to get merged into the filter params. I fixed this by adding a with_indifferent_access on the params before they are parsed.

This fixes the reopening of #33.

@@ -82,7 +93,7 @@ def self.for_report(report_id = nil, options = {}) # rubocop:disable Style/Optio
# @return [ActiveResource::PaginatedCollection<ESP::Stat>]
def self.latest_for_teams
# call find_every directly since find is overriden/not implemented
find_every(from: :latest_for_teams)
find_every(from: "#{prefix}stats/latest_for_teams")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you change this to where, you won't have to override find_every

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that seems to work. I should have started with the where override that allowed it.

¯_(ツ)_/¯

@@ -38,7 +49,7 @@ def destroy
# @return [ESP::Dashboard]
def self.recent
# call find_every directly since find is overridden/not implemented
find_every from: "#{prefix}dashboard/recent.#{format.extension}"
find_every from: "#{prefix}dashboard/recent"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you change this to where, you won't have to override find_every

@kevintyll
Copy link
Contributor

👍

@johnathanludwig johnathanludwig merged commit 3e688d0 into master Oct 19, 2016
@johnathanludwig johnathanludwig deleted the fix_stat_pagination branch October 19, 2016 14:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants