stats view
This commit is contained in:
parent
8ff5ae8974
commit
374a8f695f
|
@ -43,3 +43,31 @@ def editstops(request):
|
||||||
return render_to_response("editstops.html", context)
|
return render_to_response("editstops.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
def stats(request):
|
||||||
|
total_stops_left = Stop.objects.filter(point=None).count()
|
||||||
|
areas = []
|
||||||
|
for a in Area.objects.all():
|
||||||
|
stops = Stop.objects.filter(area=a)
|
||||||
|
d = {
|
||||||
|
'area': a,
|
||||||
|
#'area_name': a.name,
|
||||||
|
'total_stops': stops.count(),
|
||||||
|
'remaining_stops': stops.filter(point=None).count()
|
||||||
|
}
|
||||||
|
areas.append(d)
|
||||||
|
routes = []
|
||||||
|
for r in Route.objects.all():
|
||||||
|
stops = Stop.objects.filter(routedetail__route=r)
|
||||||
|
d = {
|
||||||
|
'route': r,
|
||||||
|
#'route_name': r.name,
|
||||||
|
'total_stops': stops.count(),
|
||||||
|
'remaining_stops': stops.filter(point=None).count()
|
||||||
|
}
|
||||||
|
routes.append(d)
|
||||||
|
return render_to_response("stats.html", {
|
||||||
|
'total_stops_left': total_stops_left,
|
||||||
|
'areas': areas,
|
||||||
|
'routes': routes
|
||||||
|
})
|
||||||
|
|
||||||
|
|
|
@ -36,16 +36,7 @@
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<!--
|
|
||||||
$(function() {
|
|
||||||
$("#statcontainer").load("mumbai/stats");
|
|
||||||
var refreshId = setInterval(function() {
|
|
||||||
$("#statcontainer").load('/mumbai/stats');
|
|
||||||
}, 5000);
|
|
||||||
$.ajaxSetup({ cache: false });
|
|
||||||
});
|
|
||||||
|
|
||||||
-->
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -55,13 +46,13 @@
|
||||||
ChaloBEST! The Stats..
|
ChaloBEST! The Stats..
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="stops"> <h2> We have {{ stops_left }} stops left! </h2> <br /> <br />
|
<div class="stops"> <h2> We have {{ total_stops_left }} stops left! </h2> <br /> <br />
|
||||||
|
|
||||||
<div class="routes"> <h3> Routes needing some love.. <h3><br />
|
<div class="routes"> <h3> Routes needing some love.. </h3><br />
|
||||||
<ul id="routesList">
|
<ul id="routesList">
|
||||||
{% for r in route_stat %}
|
{% for r in routes %}
|
||||||
<li class="route listItem">
|
<li class="route listItem">
|
||||||
<a href="{{r.route.get_absolute_url}}" title="view stops for route">{{ r.route.alias }} </a> needs {{ r.neededstops }} stop locations.
|
<a href="{{r.route.get_absolute_url}}" title="view stops for route">{{ r.route.alias }} </a> needs {{ r.remaining_stops }} stop locations out of {{ r.total_stops }}.
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -69,9 +60,9 @@
|
||||||
|
|
||||||
<div class="areas"> <h3> Areas needing some love.. </h3> <br />
|
<div class="areas"> <h3> Areas needing some love.. </h3> <br />
|
||||||
<ul id="AreasList">
|
<ul id="AreasList">
|
||||||
{% for a in area_stat %}
|
{% for a in areas %}
|
||||||
<li class="area listItem">
|
<li class="area listItem">
|
||||||
<a href="{{a.area.get_absolute_url}}" title="view stops for area">{{ a.area.name }}</a> needs {{ a.neededstops }} stop locations.
|
<a href="{{a.area.get_absolute_url}}" title="view stops for area">{{ a.area.name }}</a> needs {{ a.remaining_stops }} stop locations out of {{ a.total_stops }}.
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -12,7 +12,7 @@ urlpatterns = patterns('',
|
||||||
# Example:
|
# Example:
|
||||||
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
||||||
url(r'^$','chaloBEST.views.index', name='index'),
|
url(r'^$','chaloBEST.views.index', name='index'),
|
||||||
url(r'^stats/$','chaloBEST.views.stats', name='stats'),
|
url(r'^stats/$','mumbai.views.stats', name='stats'),
|
||||||
url(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root':'./static'}),
|
url(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root':'./static'}),
|
||||||
(r'^routes/$', 'mumbai.views.routes'),
|
(r'^routes/$', 'mumbai.views.routes'),
|
||||||
(r'^route/(?P<alias>[a-zA-Z0-9\s\-]*?)/$', 'mumbai.views.route'),
|
(r'^route/(?P<alias>[a-zA-Z0-9\s\-]*?)/$', 'mumbai.views.route'),
|
||||||
|
|
|
@ -27,12 +27,13 @@ def stats(request):
|
||||||
area_stat = []
|
area_stat = []
|
||||||
|
|
||||||
for area in arealist:
|
for area in arealist:
|
||||||
area_stops = area.stop_set.all()
|
# area_stops = area.stop_set.all()
|
||||||
astops_left = len(area_stops)
|
# astops_left = len(area_stops)
|
||||||
for stp in area_stops:
|
astops_left = Stop.objects.filter(area=area).filter(point=None).count()
|
||||||
if stp.point:
|
# for stp in area_stops:
|
||||||
astops_left-=1
|
# if stp.point:
|
||||||
|
# astops_left-=1
|
||||||
|
#
|
||||||
area_stat.append({'area':area,'neededstops':astops_left})
|
area_stat.append({'area':area,'neededstops':astops_left})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user