Skip to content

Commit

Permalink
Merge pull request #35 from proyectosdeley/stats
Browse files Browse the repository at this point in the history
move `sin tramitar` to first position
  • Loading branch information
aniversarioperu committed Mar 16, 2015
2 parents 530becf + e9ddc7d commit ad39bfb
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 18 deletions.
Binary file added proyectos_de_ley/pdl/static/css/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions proyectos_de_ley/pdl/static/css/timeline.css

Large diffs are not rendered by default.

Binary file added proyectos_de_ley/pdl/static/css/timeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions proyectos_de_ley/pdl/static/js/locale/es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions proyectos_de_ley/pdl/static/js/storyjs-embed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions proyectos_de_ley/pdl/static/js/timeline-min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ <h1 id="proyectos_de_ley">Proyecto de Ley {{ item.codigo }}</h1>


{% block additional_javascript %}
<script type="text/javascript" src="http://cdn.knightlab.com/libs/timeline/latest/js/storyjs-embed.js"></script>
{% load staticfiles %}
<script type="text/javascript" src="{% static 'js/storyjs-embed.js' %}"></script>

<script>
$.getJSON("/api/iniciativas/{{ item.short_url }}", function(data) {
Expand Down
18 changes: 9 additions & 9 deletions proyectos_de_ley/stats/templates/stats/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,32 @@ <h3>Número total de proyectos de ley:
<script>
var g = new JustGage({
id: "g1",
value: {{ percentage_without_pdf_url }},
label: "{{ without_pdf_url|intcomma }} proyectos",
value: {{ percentage_without_seguimientos }},
label: "{{ without_seguimientos|intcomma }} proyectos",
min: 0,
max: 100,
levelColorsGradient: false,
title: "% sin PDF link"
title: "% sin tramitar"
});

var g = new JustGage({
id: "g2",
value: {{ percentage_without_iniciativas }},
label: "{{ without_iniciativas|intcomma }} proyectos",
value: {{ percentage_total_in_commissions }},
label: "{{ total_in_commissions|intcomma }} proyectos",
min: 0,
max: 100,
levelColorsGradient: false,
title: "% proyectos sin fusionar"
title: "% en comisión \nsin dictamen"
});

var g = new JustGage({
id: "g3",
value: {{ percentage_without_seguimientos }},
label: "{{ without_seguimientos|intcomma }} proyectos",
value: {{ percentage_without_iniciativas }},
label: "{{ without_iniciativas|intcomma }} proyectos",
min: 0,
max: 100,
levelColorsGradient: false,
title: "% sin tramitar"
title: "% proyectos sin fusionar"
});

var g = new JustGage({
Expand Down
7 changes: 7 additions & 0 deletions proyectos_de_ley/stats/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pdl.models import Proyecto
from stats.models import Dispensed
from stats.models import ComisionCount
from stats import views


class TestStatsViews(TestCase):
Expand All @@ -30,3 +31,9 @@ def test_index(self):
c = Client()
response = c.get('/stats/')
self.assertEqual(200, response.status_code)

def test_dame_sin_tramitar(self):
numero_de_proyectos = Proyecto.objects.all().count()
expected = (100.0, 1)
result = views.dame_sin_tramitar(numero_de_proyectos)
self.assertEqual(expected, result)
36 changes: 28 additions & 8 deletions proyectos_de_ley/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
from stats.models import Dispensed


def dame_sin_tramitar(numero_de_proyectos):
with_seguimientos = Seguimientos.objects.values_list('proyecto_id',
flat=True).distinct().count()
without_seguimientos = numero_de_proyectos - with_seguimientos
percentage_without_seguimientos = round(
(without_seguimientos * 100) / numero_de_proyectos, 1)
return percentage_without_seguimientos, without_seguimientos


def dame_sin_dictamen(queryset, numero_de_proyectos):
count = 0
for i in queryset.values():
count += i['count']
percentage = round((count * 100) / numero_de_proyectos, 1)
return percentage, count


def index(request):
numero_de_proyectos = Proyecto.objects.all().count()

Expand All @@ -23,10 +40,9 @@ def index(request):
percentage_without_iniciativas = round(
(without_iniciativas * 100) / numero_de_proyectos, 1)

with_seguimientos = Seguimientos.objects.values_list('proyecto_id', flat=True).distinct().count()
without_seguimientos = numero_de_proyectos - with_seguimientos
percentage_without_seguimientos = round(
(without_seguimientos * 100) / numero_de_proyectos, 1)
# Sin Tramitar
percentage_without_seguimientos, without_seguimientos = dame_sin_tramitar(
numero_de_proyectos)

are_law = Proyecto.objects.exclude(
titulo_de_ley__isnull=True).exclude(
Expand All @@ -42,10 +58,12 @@ def index(request):
for i in queryset:
comision_names_str += str(i.comision) + "', '"
comision_count_str += str(i.count) + ", "

comision_names_str += "']"
comision_count_str += "]"

# sin dictamen?
percentage_total_in_commissions, total_in_commissions = dame_sin_dictamen(queryset, numero_de_proyectos)

# Projects dispensed of 2nd round of votes
res = Dispensed.objects.all()[0]
dispensed_values = "[" + str(res.total_approved) + ", " \
Expand All @@ -57,16 +75,18 @@ def index(request):
"'Dispensados por acuerdo del pleno', " \
"'Dispensados por junta portavoces', " \
"'Otros proyectos dispensados']"
print(dispensed_categories)

return render(request, "stats/index.html",
{'numero_de_proyectos': numero_de_proyectos,
{'percentage_without_seguimientos': percentage_without_seguimientos,
'percentage_total_in_commissions': percentage_total_in_commissions,
'total_in_commissions': total_in_commissions,

'numero_de_proyectos': numero_de_proyectos,
'without_pdf_url': without_pdf_url,
'percentage_without_pdf_url': percentage_without_pdf_url,
'without_iniciativas': without_iniciativas,
'percentage_without_iniciativas': percentage_without_iniciativas,
'without_seguimientos': without_seguimientos,
'percentage_without_seguimientos': percentage_without_seguimientos,
'are_not_law': are_not_law,
'percentage_are_not_law': percentage_are_not_law,
'comision_names': comision_names_str,
Expand Down

0 comments on commit ad39bfb

Please sign in to comment.