DoSomething / lofi-schools-flask

Flask implementation of the school search service
MIT License
0 stars 2 forks source link

Add pagination flag to "meta" response #2

Closed DFurnes closed 9 years ago

DFurnes commented 9 years ago

We need a "flag" in the JSON response to indicate whether more than limit results exist.

Example: http://lofischools.herokuapp.com/search?state=CT&query=c

{
   "meta":
   {
      "code": 200,
      "more_results": true
   },
   "results": [
      {
         "city": "Hartford",
         "country": "US",
         "gsid": "0900002",
         "lat": "41.742813",
         "lon": "-72.70701",
         "name": "A. I. Prince Technical High School",

/*...*/

Example #2: http://lofischools.herokuapp.com/search?state=CT&query=c&limit=50

{
   "meta":
   {
      "code": 200,
      "more_results": false
   },
   "results": [
      {
         "ALL": "THE",
         "RESULTS": "YOU COULD WANT",
         "UP TO": 50,
      }

/*...*/

If meta[more_results] is set to true, then the client knows it can request a higher limit. (A more robust solution would be to set up paging for results from the API, but that seems outside the scope of what we really need to have here.)

mshmsh5000 commented 9 years ago

@DFurnes Try this:

https://mshmsh50001-5000.terminal.com/search?state=CT&query=c https://mshmsh50001-5000.terminal.com/search?state=CT&query=c&limit=50 https://mshmsh50001-5000.terminal.com/search?state=CT&query=c&limit=1600

DFurnes commented 9 years ago

Looks great! :+1: