mxabierto / madison

(sin mantenimiento) Madison 2.0 - nos fuimos a mxabierto/participa
GNU General Public License v3.0
2 stars 1 forks source link

Add pagination to docs api #242

Closed joecohens closed 9 years ago

joecohens commented 9 years ago

/cc @chuckcfs @rodowi

screen shot 2015-05-27 at 2 41 49 pm

defvol commented 9 years ago

ᕕ( ᐛ )ᕗ

joecohens commented 9 years ago

Jajaja está genial el emoji

defvol commented 9 years ago
➜  participa git:(pagination-backend) ✗ curl "http://192.168.42.70/participa/api/docs?page=4"
{"results":[{"id":44556,"title":"Modificaci\u00f3n de la Norma Oficial Mexicana NOM-005-SSA3-2010, Que establece los requisitos m\u00ednimos de infraestructura y equipamiento de establecimientos para la atenci\u00f3n m\u00e9dica de pacientes ambulatorios, para quedar como Norma Oficial Mexicana NOM-005-SSA3","slug":"SSA-288-232","shortname":null,"init_section":null,"created_at":"2015-05-27T00:25:36+00:00","updated_at":"2015-05-27T00:25:36+00:00","deleted_at":null,"categories":[{"id":4,"name":"cofemer","created_at":"2015-05-20 15:58:24","updated_at":"2015-05-20 15:58:24","pivot":{"doc_id":44556,"category_id":4}},{"id":174,"name":"regulaci\u00f3n","created_at":"2015-05-26 22:17:50","updated_at":"2015-05-26 22:17:50","pivot":{"doc_id":44556,"category_id":174}},{"id":83,"name":"SSA","created_at":"2015-05-22 20:59:18","updated_at":"2015-05-22 20:59:18","pivot":{"doc_id":44556,"category_id":83}}],"sponsor":[{"id":3,"name":"COFEMER","address1":"","address2":"","city":"","state":"","postal_code":"","phone_number":"","display_name":"","status":"active","created_at":"0000-00-00 00:00:00","updated_at":"0000-00-00 00:00:00","deleted_at":null,"pivot":{"doc_id":44556,"group_id":3}}],"statuses":[],"dates":[]}],"pagination":{"per_page":1,"page":4,"count":1391}}% 
defvol commented 9 years ago

➜ participa git:(pagination-backend) ✗ curl --silent "http://192.168.42.70/participa/api/docs?page=4" | jq '.' | pbcopy

{
  "results": [
    {
      "id": 44556,
      "title": "Modificación de la Norma Oficial Mexicana NOM-005-SSA3-2010, Que establece los requisitos mínimos de infraestructura y equipamiento de establecimientos para la atención médica de pacientes ambulatorios, para quedar como Norma Oficial Mexicana NOM-005-SSA3",
      "slug": "SSA-288-232",
      "shortname": null,
      "init_section": null,
      "created_at": "2015-05-27T00:25:36+00:00",
      "updated_at": "2015-05-27T00:25:36+00:00",
      "deleted_at": null,
      "categories": [
        {
          "id": 4,
          "name": "cofemer",
          "created_at": "2015-05-20 15:58:24",
          "updated_at": "2015-05-20 15:58:24",
          "pivot": {
            "doc_id": 44556,
            "category_id": 4
          }
        },
        {
          "id": 174,
          "name": "regulación",
          "created_at": "2015-05-26 22:17:50",
          "updated_at": "2015-05-26 22:17:50",
          "pivot": {
            "doc_id": 44556,
            "category_id": 174
          }
        },
        {
          "id": 83,
          "name": "SSA",
          "created_at": "2015-05-22 20:59:18",
          "updated_at": "2015-05-22 20:59:18",
          "pivot": {
            "doc_id": 44556,
            "category_id": 83
          }
        }
      ],
      "sponsor": [
        {
          "id": 3,
          "name": "COFEMER",
          "address1": "",
          "address2": "",
          "city": "",
          "state": "",
          "postal_code": "",
          "phone_number": "",
          "display_name": "",
          "status": "active",
          "created_at": "0000-00-00 00:00:00",
          "updated_at": "0000-00-00 00:00:00",
          "deleted_at": null,
          "pivot": {
            "doc_id": 44556,
            "group_id": 3
          }
        }
      ],
      "statuses": [],
      "dates": []
    }
  ],
  "pagination": {
    "per_page": 1,
    "page": 4,
    "count": 1391
  }
}
defvol commented 9 years ago

Trae 1 resultado por página:

➜ participa git:(pagination-backend) ✗ curl --silent "http://192.168.42.70/participa/api/docs?page=4" | jq '.results[].slug'
"SSA-288-232" ➜ participa git:(pagination-backend) ✗ curl --silent "http://192.168.42.70/participa/api/docs?page=5" | jq '.results[].slug' "SSA-289-233"

joecohens commented 9 years ago

My fault le puse que regrese uno sólo ahora le pongo 20 por default.

defvol commented 9 years ago

ok, my bad también

➜ participa git:(pagination-backend) ✗ curl --silent "http://192.168.42.70/participa/api/docs?page=5&per_page=5" | jq '.results[].slug' "SEPRONAFIM-241-206" "SFP-146-63" "SRE-406-274" "SRE-531-183" "SRE-532-183"

joecohens commented 9 years ago

Done :)

defvol commented 9 years ago

approved by inspector 15

:godmode: :+1: