Skip to content
This repository has been archived by the owner on Aug 7, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…radar into timeline#187
  • Loading branch information
vagrant committed Jun 11, 2015
2 parents ad58595 + 6f5c91e commit f065ced
Show file tree
Hide file tree
Showing 23 changed files with 575 additions and 204 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ python:

# Dependencias do projeto
install:
# Criar um requirements para o ambiente de testes?
- pip install -r radar_parlamentar/requirements.txt --use-mirrors
- pip install coveralls

# Roda Testes
script: cd radar_parlamentar/ ; source tests.sh
script:
- cd radar_parlamentar/ ; source tests.sh
- coverage run --source=modelagem,analises,exportadores,importadorInterno,importadores,radar_parlamentar manage.py test modelagem analises exportadores importadorInterno importadores radar_parlamentar

after_success:
- coveralls
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Radar Parlamentar

[![Build Status](https://travis-ci.org/radar-parlamentar/radar.svg?branch=master)](https://travis-ci.org/radar-parlamentar/radar)

[![Coverage Status](https://coveralls.io/repos/radar-parlamentar/radar/badge.svg?branch=master)](https://coveralls.io/r/radar-parlamentar/radar?branch=master)

Este projeto utiliza dados abertos para analisar os votos de parlamentares em diferentes casas legislativas do Brasil.

O Radar Parlamentar determina "semelhanças" entre partidos políticos baseado na análise matemática dos dados de votações de projetos de lei na casa legislativa. Essas semelhanças são apresentadas em um gráfico bi-dimensional, em que círculos representam partidos e a distância entre esses círculos representa o quão parecido esses partidos votam.
Expand All @@ -11,13 +13,10 @@ Site em produção: [Radar Parlamentar](http://radarparlamentar.polignu.org/ "Ra

Wiki: https://github.com/radar-parlamentar/radar/wiki

Servidor de integração contínua: http://200.144.254.67:60581/

Licença do projeto: *AGPL v3*

Seja bem vindo,

Leonardo Leite





38 changes: 36 additions & 2 deletions radar_parlamentar/cron/cache-analises.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
#!/bin/bash
# invoca rotinas de análise para que os resultados fiquem guardados no cache
curl http://localhost/analises/json_analise/cmsp/BIENIO/
# Invoca rotinas de análise para que os resultados fiquem guardados no cache

periodicidades=("QUADRIENIO" "BIENIO" "ANO" "SEMESTRE")
casas_legislativas=("cmsp" "cdep" "sen")
porta_development=8000

if [[ "$DJANGO_SETTINGS_MODULE" == "settings.development" ]]; then
base_url="http://localhost:$porta_development"
else
base_url="http://localhost"
fi

echo "Iniciando a rotina de cache das analises em '$(date)'"
inicio=$(date '+%s')

for casa in ${casas_legislativas[*]}; do
for periodicidade in ${periodicidades[*]}; do
url="$base_url/analises/json_analise/$casa/$periodicidade/"
echo "curl $url"
curl --fail --silent --show-error $url > /dev/null

rc=$?
if [[ $rc != 0 ]]; then
echo "Erro executando o curl para $url"
fi
done
done

fim=$(date '+%s')
dt=$((fim - inicio))
ds=$((dt % 60))
dm=$(((dt / 60) % 60))
dh=$((dt / 3600))

echo "Finalizando a rotina de cache das analises em '$(date)'."
printf "Se passaram %dh %02dmin %02ds\n\n" $dh $dm $ds
2 changes: 2 additions & 0 deletions radar_parlamentar/cron/clear-cache.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/bash

echo -e "Limpando o cache do radar"
sudo rm -rf /tmp/django_cache/*
40 changes: 0 additions & 40 deletions radar_parlamentar/cron/crontab

This file was deleted.

4 changes: 3 additions & 1 deletion radar_parlamentar/cron/dump-radar.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/bash
pg_dump -h localhost -U radar radar --inserts -t modelagem_* -f $RADAR_HOME/static/db-dump/radar.sql
# Argumento: arquivo de saída (onde o dump será salvo)
echo "Gerando dump completo do banco em '$(date)'"
pg_dump -h localhost -U radar radar --inserts -t modelagem_* -f $1
48 changes: 30 additions & 18 deletions radar_parlamentar/exportadores/exportar.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,50 +39,62 @@ def serialize_partido():
XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
filepath = os.path.join(MODULE_DIR, 'dados/partido.xml')
out = open(filepath, "w")
xml_serializer.serialize(models.Partido.objects.all(), stream=out)

with open(filepath, "w") as out:
xml_serializer.serialize(models.Partido.objects.all(), stream=out)


def serialize_casa_legislativa():
XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
out = open(os.path.join(MODULE_DIR, 'dados/casa_legislativa.xml'), "w")
xml_serializer.serialize(models.CasaLegislativa.objects.all(), stream=out)

filepath = os.path.join(MODULE_DIR, 'dados/casa_legislativa.xml')

with open(filepath, "w") as out:
xml_serializer.serialize(models.CasaLegislativa.objects.all(), stream=out)

def serialize_parlamentar():
XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
out = open(os.path.join(MODULE_DIR, 'dados/parlamentar.xml'), "w")
xml_serializer.serialize(models.Parlamentar.objects.all(), stream=out)
filepath = os.path.join(MODULE_DIR, 'dados/parlamentar.xml')

with open(filepath, "w") as out:
xml_serializer.serialize(models.Parlamentar.objects.all(), stream=out)


def serialize_legislatura():
XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
out = open(os.path.join(MODULE_DIR, 'dados/legislatura.xml'), "w")
xml_serializer.serialize(models.Legislatura.objects.all(), stream=out)
filepath = os.path.join(MODULE_DIR, 'dados/legislatura.xml')

with open(filepath, "w") as out:
xml_serializer.serialize(models.Legislatura.objects.all(), stream=out)


def serialize_proposicao():
XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
out = open(os.path.join(MODULE_DIR, 'dados/proposicao.xml'), "w")
xml_serializer.serialize(models.Proposicao.objects.all(), stream=out)
filepath = os.path.join(MODULE_DIR, 'dados/proposicao.xml')

with open(filepath, "w") as out:
xml_serializer.serialize(models.Proposicao.objects.all(), stream=out)


def serialize_votacao():
XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
out = open(os.path.join(MODULE_DIR, 'dados/votacao.xml'), "w")
xml_serializer.serialize(models.Votacao.objects.all(), stream=out)
filepath = os.path.join(MODULE_DIR, 'dados/votacao.xml')

with open(filepath, "w") as out:
xml_serializer.serialize(models.Votacao.objects.all(), stream=out)


def serialize_voto():
XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
out = open(os.path.join(MODULE_DIR, 'dados/voto.xml'), "w")
voto = models.Voto.objects.all()
for e in voto:
e.id = None
xml_serializer.serialize(voto, stream=out)
filepath = os.path.join(MODULE_DIR, 'dados/voto.xml')

with open(filepath, "w") as out:
voto = models.Voto.objects.all()
for e in voto:
e.id = None
xml_serializer.serialize(voto, stream=out)
Loading

0 comments on commit f065ced

Please sign in to comment.