Giter Site home page Giter Site logo

olhoneles / politicos-go Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 74 KB

API com todos os candidatos Brasileiros!

Home Page: https://politicos.olhoneles.org

License: GNU Affero General Public License v3.0

Go 99.37% Makefile 0.63%
elections open-data political-networks political-parties political-party politicians politics prefeitos presidente vereadores

politicos-go's Introduction

Olho Neles Code Health Build Status

Tool to monitor Brazilian legislators expenses while in the exercise of their mandates.

Install

  1. Clone the repository:

    git clone https://github.com/olhoneles/olhoneles.git
    
  2. Create a virtualenv:

    cd olhoneles
    mkvirtualenv olhoneles
    
  3. Install dependencies:

    make setup
    
  4. Create your database:

    make data
    
  5. Run it:

    make run
    
  6. Change default configs:

    If you would like to override some settings.py variables, like SECRET_KEY, DATABASES, ALLOWED_HOSTS, please create the olhoneles/local.config file.

Collecting the data

After setting up, you can collect one of the supported legislative houses (cmbh, almg, cmsp, senado) by using the collect command like this:

./manage.py collect <house>

You can add --debug after the name of the house to get a more verbose output. Note that the collection process happens in a transaction and that the expenses are not added to the main Expense table while the collection is running, so you will not see partial data in the site while collecting.

API

Yes, we have an API. The Olho Neles API lets you build tools using all data we have collected from legislative houses. All endpoints, parameters and error messages available to the Olho Neles API are docummented.

Contribute

Join us at the dev-mailing list and at #olhoneles on Freenode.

Fork the repository and send your pull-requests.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

politicos-go's People

Contributors

cristiandean avatar luccamendonca avatar marcelometal avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

cristiandean

politicos-go's Issues

Create API response

The Politicos API v0 has the following response data:

{
    "meta":{
        "limit":20,
        "next":"/api/v0/political-parties/?limit=20&offset=20",
        "offset":0,
        "previous":null,
        "total_count":1
    },
    "objects":[
        {
            "founded_date":null,
            "id":1,
            "logo":null,
            "name":"Heavy Metal",
            "resource_uri":"/api/v0/political-parties/1/",
            "siglum":"HV",
            "tse_number":666,
            "website":null,
            "wikipedia":null
        }
    ]
}

Now we can think about the new response data or keep the current response.

WIP: API routes

Candidacies

  • GET /api/v0/candidacies/
  • GET /api/v0/candidacies/{id}

Candidacies Status

  • GET /api/v0/candidacies-status/
  • GET /api/v0/candidacies-status/{id}

Cities

  • GET /api/v0/cities/
  • GET /api/v0/cities/{id}
  • GET /api/v0/cities/search

Countries

  • GET /api/v0/countries/
  • GET /api/v0/countries/{id}

Educations

  • GET /api/v0/educations/
  • GET /api/v0/educations/{id}

Election Rounds

  • GET /api/v0/election-rounds/
  • GET /api/v0/election-rounds/{id}

Elections

  • GET /api/v0/elections/
  • GET /api/v0/elections/{id}

Ethnicities

  • GET /api/v0/ethnicities/
  • GET /api/v0/ethnicities/{id}

Institutions

  • GET /api/v0/institutions/
  • GET /api/v0/institutions/{id}

Mandate Event Types

  • GET /api/v0/mandate-event-types/
  • GET /api/v0/mandate-event-types/{id}

Mandate Events

  • GET /api/v0/mandate-events/
  • GET /api/v0/mandate-events/{id}

Mandates

  • GET /api/v0/mandates/
  • GET /api/v0/mandates/{id}

Marital Status

  • GET /api/v0/marital-status/
  • GET /api/v0/marital-status/{id}

Nationalities

  • GET /api/v0/nationalities/
  • GET /api/v0/nationalities/{id}

Occupations

  • GET /api/v0/occupations/
  • GET /api/v0/occupations/{id}
  • GET /api/v0/occupations/search/

Political Offices

  • GET /api/v0/political-offices/
  • GET /api/v0/political-offices/{id}

Political Parties

  • GET /api/v0/political-parties/
  • GET /api/v0/political-parties/{id}

Politician Event Types

  • GET /api/v0/politician-event-types/
  • GET /api/v0/politician-event-types/{id}

Politician Events

  • GET /api/v0/politician-events/
  • GET /api/v0/politician-events/{id}

Politicians

  • GET /api/v0/politicians/
  • GET /api/v0/politicians/{id}
  • GET /api/v0/politicians/search

States

  • GET /api/v0/states/
  • GET /api/v0/states/{id}

CLI: Create post-process command

Please, don't repeat yourself!

Today there are these CLI commands:

  • post-process-candidacies-status
  • post-process-education
  • post-process-political-office
  • post-process-political-party

But we could create post-process command and using candidacies-status, education, political-office and political-party as arg value

Merge all cand20xx.go files

From what I realized, the Cand20XX structs are almost the same, with only a few increments each year.

We could see if we can merge them into a single generic structure, and the missing fields could be filled in as empty. What do you think?

Only download the zip files if necessary

Using HTTP headers we can avoid to download the same file.

Headers: Last-Modified and Content-Length

$ curl -I http://agencia.tse.jus.br/estatistica/sead/odsele/consulta_cand/consulta_cand_2018.zip

HTTP/1.1 200 OK
Server: Apache/2.2.15 (Red Hat)
Last-Modified: Mon, 16 Nov 2020 01:00:05 GMT
ETag: "10118c-641f67-5b42ee6194614"
Accept-Ranges: bytes
Content-Length: 6561639
Content-Type: application/zip
F5-IpCliente: 189.36.X.X
ClientIP: 189.36.X.X
Server: thttpd/2.26 ??apr2004
Date: Mon, 16 Nov 2020 03:05:31 GMT
Connection: keep-alive
Set-Cookie: BIGipServerPool_Apache=197961920.20480.0000; path=/; Httponly

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.