Skip to content

Commit

Permalink
make sure order of values is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
aniversarioperu committed Dec 7, 2014
1 parent bf62cb4 commit 8133755
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
11 changes: 11 additions & 0 deletions proyectos_de_ley/pdl/static/js/Chart.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ def handle(self, *args, **options):
# There are 24 `comisiones` in total
comisiones = set()
for i in queryset:
res = re.match("(en\s+comisión(\s\w+,*)+)", i.evento, re.I)
# res = re.match("(en\s+comisión(\s\w+,*)+)", i.evento, re.I)
res = re.match("(en\s+comisión(\s\w+)+)", i.evento, re.I)
if res:
comisiones.add(res.groups()[0])
this_comision = re.sub("En\s+comisión\s+", "", res.groups()[0])
this_comision = re.sub("\s+y\s+.+", "", this_comision)
comisiones.add(this_comision)

queryset = Seguimientos.objects.order_by('proyecto_id', '-fecha').distinct('proyecto_id')
comisiones_count = {}
Expand All @@ -34,3 +37,4 @@ def handle(self, *args, **options):
obj, created = ComisionCount.objects.update_or_create(
comision=k, count=v
)
print(obj, created)
23 changes: 23 additions & 0 deletions proyectos_de_ley/stats/templates/stats/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% extends "pdl/base.html" %}


{% load staticfiles %}
{% block additional_head_javascript %}
<script src='{% static "js/Chart.min.js" %}'></script>
{% endblock additional_head_javascript %}


Expand Down Expand Up @@ -38,6 +40,11 @@ <h3>Número total de proyectos de ley:
<div id="g4"></div>

</div><!-- container -->

<div class="container">
<h4>Número de proyectos estancados en cada comisión del Congreso</h3>
<canvas id="comisiones_chart" width="600" height="300"></canvas>
</div>
</div>


Expand All @@ -49,6 +56,22 @@ <h3>Número total de proyectos de ley:
<script src="{% static 'js/justgage.1.0.1.min.js' %}"></script>

<script>
var ctx = document.getElementById("comisiones_chart").getContext("2d");
var data = {
labels: {{ comision_names|safe }},
datasets: [
{
label: "My firt dataset",
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: {{ comision_count|safe }}
}
]
};
var comisiones_chart = new Chart(ctx).Bar(data);

var g = new JustGage({
id: "g1",
value: {{ percentage_without_pdf_url }},
Expand Down
10 changes: 10 additions & 0 deletions proyectos_de_ley/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pdl.models import Proyecto
from pdl.models import Seguimientos
from stats.models import ComisionCount


def index(request):
Expand Down Expand Up @@ -33,6 +34,13 @@ def index(request):
percentage_are_not_law = round(
(are_not_law * 100) / numero_de_proyectos, 1)

queryset = ComisionCount.objects.all()
comision_names = set()
comision_count = set()
for i in queryset:
comision_names.add(i.comision)
comision_count.add(i.count)

return render(request, "stats/index.html",
{'numero_de_proyectos': numero_de_proyectos,
'without_pdf_url': without_pdf_url,
Expand All @@ -43,5 +51,7 @@ def index(request):
'percentage_without_seguimientos': percentage_without_seguimientos,
'are_not_law': are_not_law,
'percentage_are_not_law': percentage_are_not_law,
'comision_names': list(comision_names),
'comision_count': list(comision_count),
}
)

0 comments on commit 8133755

Please sign in to comment.