Code Monkey home page Code Monkey logo

imago's Introduction

Open Civic Data Technical Documentation

This repository contains documentation for developers including:

  • Writing Scrapers using Pupa
  • Open Civic Data's Data Type Specifications
  • Open Civic Data Proposals

Read these docs at https://open-civic-data.readthedocs.io/en/latest/

imago's People

Contributors

boblannon avatar dcloud avatar derekeder avatar fgregg avatar jamesturk avatar menerve avatar mileswwatkins avatar mjumbewu avatar paultag avatar rshorey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

imago's Issues

should we consider dropping imago?

are others using imago?

I don't think we're likely to use this for Open States' new API, in large part b/c this is based on https://github.com/dobarkod/django-restless which hasn't seen an update in ~2 years. (we went down this road w/ django-piston, leading to a fair amount of regret)

Probably about equally feature-complete I have https://github.com/openstates/ocd-jsonapi/ which is based on django-rest-framework (a well supported & maintained library) and which is compatible with the http://jsonapi.org/ spec. I'm not sure if we'll go that route either but I figured I'd mention it as an option.

(I'm also somewhat interested in exploring something GraphQL inspired for Open States API v2, if that is of interest to anyone else)

Fix pagination in boundaries endpoint

As of now, the boundaries endpoint is the only endpoint that uses offset + limit pagination. All the others use page.

For consistency's sake and ease of usage, I think it'd be best to change the paging on the boundaries endpoint to page, if possible.

Search endpoints vary in case sensitivity and substring/fullstring requirements

Agenda items lacking related bill entities cause ocd-event endpoint error

We were only adding related bills to agenda items when it was a "votable" event, assuming that informational and presentation agenda items didn't have related bills.

2016-03-14T05:39:45.732774+00:00 heroku[router]: at=info method=GET path="/ocd-event/f00dbad3-1537-4877-95af-7698492340e4" host=toronto-ocd-api.herokuapp.com request_id=eac1fb43-a602-449d-906a-1910b40c99cf fwd="174.117.101.98" dyno=web.1 connect=0ms service=3ms status=301 bytes=248
2016-03-14T05:39:45.730297+00:00 app[web.1]: WARNING Not Found: /ocd-event/f00dbad3-1537-4877-95af-7698492340e4
2016-03-14T05:39:45.832606+00:00 app[web.1]: ERROR Internal Server Error: /ocd-event/f00dbad3-1537-4877-95af-7698492340e4/
2016-03-14T05:39:45.832617+00:00 app[web.1]: Traceback (most recent call last):
2016-03-14T05:39:45.832618+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
2016-03-14T05:39:45.832622+00:00 app[web.1]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
2016-03-14T05:39:45.832619+00:00 app[web.1]:     response = self.process_exception_by_middleware(e, request)
2016-03-14T05:39:45.832620+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
2016-03-14T05:39:45.832632+00:00 app[web.1]:     return self.dispatch(request, *args, **kwargs)
2016-03-14T05:39:45.832632+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/django/views/generic/base.py", line 68, in view
2016-03-14T05:39:45.832634+00:00 app[web.1]:     return bound_func(*args, **kwargs)
2016-03-14T05:39:45.832635+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
2016-03-14T05:39:45.832633+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/django/utils/decorators.py", line 67, in _wrapper
2016-03-14T05:39:45.832635+00:00 app[web.1]:     return view_func(*args, **kwargs)
2016-03-14T05:39:45.832636+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/django/utils/decorators.py", line 63, in bound_func
2016-03-14T05:39:45.832637+00:00 app[web.1]:     return func.__get__(self, type(self))(*args2, **kwargs2)
2016-03-14T05:39:45.832638+00:00 app[web.1]:     response = super(Endpoint, self).dispatch(request, *args, **kwargs)
2016-03-14T05:39:45.832637+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/views.py", line 106, in dispatch
2016-03-14T05:39:45.832639+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/django/views/generic/base.py", line 88, in dispatch
2016-03-14T05:39:45.832640+00:00 app[web.1]:     return fn(self, request, *args, **kwargs)
2016-03-14T05:39:45.832639+00:00 app[web.1]:     return handler(request, *args, **kwargs)
2016-03-14T05:39:45.832640+00:00 app[web.1]:   File "/app/.heroku/src/imago-master/imago/helpers.py", line 137, in _
2016-03-14T05:39:45.832641+00:00 app[web.1]:     return fn(self, request, *args, **kwargs)
2016-03-14T05:39:45.832641+00:00 app[web.1]:   File "/app/.heroku/src/imago-master/imago/helpers.py", line 122, in _
2016-03-14T05:39:45.832642+00:00 app[web.1]:   File "/app/.heroku/src/imago-master/imago/helpers.py", line 391, in get
2016-03-14T05:39:45.832642+00:00 app[web.1]:     serialized = serialize(obj, **config)
2016-03-14T05:39:45.832643+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 205, in serialize
2016-03-14T05:39:45.832643+00:00 app[web.1]:     exclude=exclude, fixup=fixup)
2016-03-14T05:39:45.832644+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 109, in serialize_model
2016-03-14T05:39:45.832644+00:00 app[web.1]:     data[k] = serialize(getattr(obj, k), **v)
2016-03-14T05:39:45.832645+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 193, in serialize
2016-03-14T05:39:45.832645+00:00 app[web.1]:     return [subs(i) for i in src.all()]
2016-03-14T05:39:45.832645+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 193, in <listcomp>
2016-03-14T05:39:45.832646+00:00 app[web.1]:     return [subs(i) for i in src.all()]
2016-03-14T05:39:45.832646+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 190, in subs
2016-03-14T05:39:45.832647+00:00 app[web.1]:     exclude=exclude, fixup=fixup)
2016-03-14T05:39:45.832647+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 205, in serialize
2016-03-14T05:39:45.832648+00:00 app[web.1]:     exclude=exclude, fixup=fixup)
2016-03-14T05:39:45.832648+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 109, in serialize_model
2016-03-14T05:39:45.832648+00:00 app[web.1]:     data[k] = serialize(getattr(obj, k), **v)
2016-03-14T05:39:45.832649+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 193, in serialize
2016-03-14T05:39:45.832649+00:00 app[web.1]:     return [subs(i) for i in src.all()]
2016-03-14T05:39:45.832650+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 193, in <listcomp>
2016-03-14T05:39:45.832650+00:00 app[web.1]:     return [subs(i) for i in src.all()]
2016-03-14T05:39:45.832650+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 190, in subs
2016-03-14T05:39:45.832651+00:00 app[web.1]:     exclude=exclude, fixup=fixup)
2016-03-14T05:39:45.832651+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 205, in serialize
2016-03-14T05:39:45.832651+00:00 app[web.1]:     exclude=exclude, fixup=fixup)
2016-03-14T05:39:45.832652+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/restless/models.py", line 109, in serialize_model
2016-03-14T05:39:45.832652+00:00 app[web.1]:     data[k] = serialize(getattr(obj, k), **v)
2016-03-14T05:39:45.832652+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.4/site-packages/opencivicdata/models/event.py", line 121, in entity_name
2016-03-14T05:39:45.832671+00:00 app[web.1]: AttributeError: 'Bill' object has no attribute 'name'
2016-03-14T05:39:45.832667+00:00 app[web.1]:     return self.bill.name
2016-03-14T05:39:45.891105+00:00 heroku[router]: at=info method=GET path="/ocd-event/f00dbad3-1537-4877-95af-7698492340e4/" host=toronto-ocd-api.herokuapp.com request_id=6edf762e-6ce7-4ada-84fd-3245d7e4d6ed fwd="174.117.101.98" dyno=web.1 connect=0ms service=92ms status=500 bytes=210

code cleanup

go through the code and tighten it up.

I've done a few starts and stops. Clean out unneeded cruft.

'default' subdocument views

.. rather then dump whole objects, doing ?fields=foo should be a default view of foo rather then all the fields.

Limit related entities

I get the gut feeling we can DoS / avoid pagination limits by hitting a related field on an object detail / list view.

We should limit the number of elements we return on related entities.

(I'm thinking jurisdiction.events or something, not in particular, but to give an example of the route you can use)

Settle default key sets

I did a first pass, it's got pretty sane defaults, but we should go through and see if there's anything we want to cut/add.

Vote listings are showing too much information

We should probably have the vote listings show less information

http://ocd.datamade.us/ocd-vote/2d1ad08c-83af-4795-991b-239d7f027821/

{
    "voter_name": "Balcer, James",
    "voter": 

    {
        "image": "",
        "sort_name": "",
        "created_at": "2015-12-25T16:26:25.575",
        "id": "ocd-person/b0d09c1d-4b9c-445f-bee5-848f0aac04b8",
        "gender": "",
        "locked_fields": "[]",
        "national_identity": "",
        "family_name": "",
        "given_name": "",
        "summary": "",
        "birth_date": "",
        "death_date": "",
        "extras": "{}",
        "name": "Balcer, James",
        "biography": "",
        "updated_at": "2015-12-25T16:26:25.575"
    },
    "option": "yes",
    "note": ""
},

At the least, we should remove "locked_fields" I think we should cut even further back. Maybe only include the ocd_id.

bill search on sponsors.id not working

curl -X "GET" "https://api.opencivicdata.org/bills/?sponsors.id=ocd-person%2F3b5daa7c-f127-472f-9bde-39d80f18e907&fields=id%2Ctitle"

will return an http 500.

Restore old query behavior

Stuff like ?name=Obama, where it did a name__icontains. There was some typing type stuff. Let's bring that back.

Infra is mostly in place with adjust_filters (sorta). This is just syntax sugar for a full name__icontains

views are slow

I'm guessing we should prefetch some stuff rather then select for each.

We've got the select keys always, so this should be doable.

Getting field key error for given_name for detail people view

On my local machine:

// 20150521104713
// http://10.42.2.102/ocd-person/076e5dae-ca9a-460a-bcae-7ff925b620d8/
{
  "traceback": "Traceback (most recent call last):\n  File \"/projects/api.opencivicdata.org/src/imago/imago/helpers.py\", line 94, in get_fields\n    ret = {x: fwrap(root[x]) for x in concrete}\n  File \"/projects/api.opencivicdata.org/src/imago/imago/helpers.py\", line 94, in <dictcomp>\n    ret = {x: fwrap(root[x]) for x in concrete}\nKeyError: 'given_name'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/projects/api.opencivicdata.org/virt/lib/python3.4/site-packages/restless/views.py\", line 106, in dispatch\n    response = super(Endpoint, self).dispatch(request, *args, **kwargs)\n  File \"/projects/api.opencivicdata.org/virt/lib/python3.4/site-packages/django/views/generic/base.py\", line 87, in dispatch\n    return handler(request, *args, **kwargs)\n  File \"/projects/api.opencivicdata.org/src/imago/imago/helpers.py\", line 137, in _\n    return fn(self, request, *args, **kwargs)\n  File \"/projects/api.opencivicdata.org/src/imago/imago/helpers.py\", line 122, in _\n    return fn(self, request, *args, **kwargs)\n  File \"/projects/api.opencivicdata.org/src/imago/imago/helpers.py\", line 381, in get\n    related, config = get_fields(self.serialize_config, fields=fields)\n  File \"/projects/api.opencivicdata.org/src/imago/imago/helpers.py\", line 96, in get_fields\n    raise FieldKeyError(*e.args)\nimago.helpers.FieldKeyError: <FieldKeyError: given_name>\n",
  "error": "<FieldKeyError: given_name>"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.