stat page addedfor stop mapping sprint

This commit is contained in:
Johnson Chetty 2012-02-22 14:02:34 +01:00
parent 8401078ab0
commit d9406bc272
4 changed files with 127 additions and 2 deletions

View File

@ -54,7 +54,7 @@ def routeWithSomeLocationData(route,limit):
pass pass
if errs <=limit: if errs <=limit:
return dict({'route':route, 'neededstops':stoplist, }) return dict({'route':route, 'neededstops':len(stoplist) })
else: else:
return None return None

View File

@ -0,0 +1,80 @@
{% extends 'base.html' %}
{% block title %}
STATISTICS
{% endblock %}
{% block head %}
<meta http-equiv="refresh" content="45">
<style type ="text/css">
body {
width: 80%;
margin: 0 auto;
background-color:#ff9900
}
.header {
color:#000000;
background-color:#ff9900;
}
.stops {
color:#000000;
background-color:#ff9900;
}
.routes {
color:#000000;
background-color:#ccff99;
}
.areas {
color:#000000;
background-color:#00ccff;
}
</style>
<script type="text/javascript">
<!--
$(function() {
$("#statcontainer").load("mumbai/stats");
var refreshId = setInterval(function() {
$("#statcontainer").load('/mumbai/stats');
}, 5000);
$.ajaxSetup({ cache: false });
});
-->
</script>
{% endblock %}
{% block body %}
<div class="header" >
<h1>
ChaloBEST! The Stats..
</h1>
</div>
<div class="stops"> <h2> We have {{ stops_left }} stops left! </h2> <br /> <br />
<div class="routes"> <h3> Routes needing some love.. <h3><br />
<ul id="routesList">
{% for r in route_stat %}
<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.
</li>
{% endfor %}
</ul>
<div class="areas"> <h3> Areas needing some love.. </h3> <br />
<ul id="AreasList">
{% for a in area_stat %}
<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.
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -12,6 +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'^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'),
@ -24,6 +25,7 @@ urlpatterns = patterns('',
#(r'^grappelli/', include('grappelli.urls')), #(r'^grappelli/', include('grappelli.urls')),
# Uncomment the next line to enable the admin: # Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)), (r'^admin/', include(admin.site.urls)),
) )
if settings.LOCAL_DEVELOPMENT: if settings.LOCAL_DEVELOPMENT:

View File

@ -2,9 +2,52 @@ from django.shortcuts import redirect
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.http import HttpResponse from django.http import HttpResponse
from django.template import RequestContext
import json import json
from os.path import join from os.path import join
from gtfs.gtfs_export import *
def index(request): def index(request):
return render_to_response('index.html', {} ) return render_to_response('index.html', {} )
def stats(request):
#No. of stops left
total_stops = Stop.objects.count()
stops_left = total_stops
for stp in Stop.objects.all():
if stp.stoplocation_set.all():
stops_left-=1
#list of of areas having stops left
arealist = Area.objects.all()
area_stat = []
for area in arealist:
area_stops = area.stop_set.all()
astops_left = len(area_stops)
for stp in area_stops:
if stp.stoplocation_set.all():
astops_left-=1
area_stat.append({'area':area,'neededstops':astops_left})
#Routes having min stops left...
route_stats_temp = getRoutesHavingSomeLocs(5)
route_stat = []
for routedict in route_stats_temp:
if routedict['neededstops']:
route_stat.append(routedict)
ret = {}
ret['area_stat'] = area_stat
ret['route_stat'] = route_stat
ret['stops_left'] = stops_left
#return ret
return render_to_response('stats.html', ret)