stats revised.
This commit is contained in:
parent
6583fae18b
commit
9226891700
|
@ -200,9 +200,7 @@ def getserial(rdlist,stop):
|
|||
#check if rdlist is of a ring route..
|
||||
if rdlist[0].route.code[3]== 'R' or '4' :
|
||||
# write ring specific code here. rings have multiple occuring stops, which one to choose??
|
||||
return None
|
||||
|
||||
|
||||
return None
|
||||
|
||||
for rd in rdlist:
|
||||
if(rd.stop==stop):
|
||||
|
@ -215,15 +213,31 @@ def export_stop_times(routelist):
|
|||
#routelist = getRoutesHavingAllLocs()
|
||||
|
||||
#1. get routeDetails
|
||||
#2.
|
||||
#2. get unique routes as unr and the routeDetails subset as rd_subset for that uniqueroute
|
||||
#3. get unr.routeschedule as unr.rs ?? why is it multiple?
|
||||
#4. get total distance as tdist from rd_subset
|
||||
#5. get runtime from unr.rs
|
||||
#6. if runtime1 is null, then runtime = abs(first_from - first_to)
|
||||
#7. avgspeed = tdist/runtime... if runtime is not available then ??
|
||||
#8.
|
||||
|
||||
for r in routelist:
|
||||
rds = RouteDetail.objects.filter(route=r).order_by('serial')
|
||||
rdlist = RouteDetail.objects.filter(route=r).order_by('serial')
|
||||
sr_no=0
|
||||
for unr in UniqueRoute.objects.filter(route=r).order_by('id'):
|
||||
unrs = UniqueRoute.objects.filter(route=r).order_by('id')
|
||||
|
||||
for unr in unrs:
|
||||
from_stop = unr.from_stop
|
||||
to_stop = unr.to_stop
|
||||
rd_subset = rds[getserial(rdlist,from_stop):getserial(rdlist,to_stop)]
|
||||
sr_no +=1
|
||||
to_stop = unr.to_stop
|
||||
rd_subset = rdlist[getserial(rdlist,from_stop):getserial(rdlist,to_stop)]
|
||||
dist=0
|
||||
for rd in rd_subset:
|
||||
dist += rd.km
|
||||
runtime = unr.runtime1
|
||||
if not runtime:
|
||||
rs = unr.routeschedule_set.all()[0]
|
||||
#if rs.
|
||||
sr_no +=1
|
||||
for rd in rd_subset:
|
||||
filedude.writerow([r.code+"_"+sr_no,"","",rd.stop.id,rd.serial])
|
||||
|
||||
|
@ -236,7 +250,7 @@ stop_times.txt
|
|||
2. Get rdlist = routedetails for that route.order_by('serial'). Get UniqueRoutes for the route.
|
||||
3. --- scenario -- Not considering uniqueroutes--
|
||||
3.1 For rd in rdlist
|
||||
3.1.1 filewrite (trip_id,,,stopid,stop.serial)
|
||||
73.1.1 filewrite (trip_id,,,stopid,stop.serial)
|
||||
|
||||
----alternate scenario
|
||||
3. For each UniqueRoute, get from_to stops list (rdsubset) from RouteDetail list
|
||||
|
@ -267,5 +281,13 @@ def export_frequencies():
|
|||
filedude.writerow(["289_1","16:00:00","22:00:00",420])
|
||||
filedude.writerow(["289_1","07:00:00","11:00:00",540])
|
||||
|
||||
|
||||
def fire_up():
|
||||
routelist = getRoutesHavingAllLocs()
|
||||
export_routes(routelist)
|
||||
#export_stops()
|
||||
export_frequencies()
|
||||
export_stop_times()
|
||||
export_calendar()
|
||||
export_trips()
|
||||
export_agency()
|
||||
|
||||
|
|
|
@ -1,33 +1 @@
|
|||
trip_id,arrival_time,departure_time,stop_id,stop_sequence
|
||||
2820_1,,,1188,1
|
||||
2820_1,,,1189,2
|
||||
2820_1,,,1190,3
|
||||
2820_1,,,1191,4
|
||||
2820_1,,,1834,5
|
||||
2820_1,,,1192,6
|
||||
2820_1,,,1193,7
|
||||
2820_1,,,1214,8
|
||||
2820_1,,,1197,9
|
||||
2820_1,,,1199,10
|
||||
2820_1,,,1198,11
|
||||
2894_1,,,1188,1
|
||||
2894_1,,,1189,2
|
||||
2894_1,,,1190,3
|
||||
2894_1,,,1191,4
|
||||
2894_1,,,1834,5
|
||||
2894_1,,,1192,6
|
||||
2894_1,,,1193,7
|
||||
2894_1,,,1197,8
|
||||
2894_1,,,1822,9
|
||||
2894_1,,,1928,10
|
||||
2894_1,,,1929,11
|
||||
2894_1,,,1196,12
|
||||
2894_1,,,1195,13
|
||||
2894_1,,,1194,14
|
||||
2894_1,,,1193,15
|
||||
2894_1,,,1192,16
|
||||
2894_1,,,1834,17
|
||||
2894_1,,,1191,18
|
||||
2894_1,,,1190,19
|
||||
2894_1,,,1189,20
|
||||
2894_1,,,1188,21
|
||||
|
|
|
@ -45,6 +45,7 @@ def editstops(request):
|
|||
|
||||
def stats(request):
|
||||
total_stops_left = Stop.objects.filter(point=None).count()
|
||||
total_stops = Stop.objects.count()
|
||||
areas = []
|
||||
for a in Area.objects.all():
|
||||
stops = Stop.objects.filter(area=a)
|
||||
|
@ -52,7 +53,9 @@ def stats(request):
|
|||
'area': a,
|
||||
#'area_name': a.name,
|
||||
'total_stops': stops.count(),
|
||||
'remaining_stops': stops.filter(point=None).count()
|
||||
'remaining_stops': stops.filter(point=None).count(),
|
||||
'stops_done': stops.filter(point__isnull=False).count(),
|
||||
|
||||
}
|
||||
areas.append(d)
|
||||
routes = []
|
||||
|
@ -62,12 +65,24 @@ def stats(request):
|
|||
'route': r,
|
||||
#'route_name': r.name,
|
||||
'total_stops': stops.count(),
|
||||
'remaining_stops': stops.filter(point=None).count()
|
||||
'remaining_stops': stops.filter(point=None).count(),
|
||||
'stops_done': stops.filter(point__isnull=False).count(),
|
||||
}
|
||||
routes.append(d)
|
||||
|
||||
areas_sorted = sorted(areas, key=lambda k: k['remaining_stops'])
|
||||
|
||||
routes_sorted = sorted(routes, key=lambda k: k['remaining_stops'])
|
||||
|
||||
routes = routes_sorted
|
||||
areas = areas_sorted
|
||||
return render_to_response("stats.html", {
|
||||
'total_stop_count': total_stops,
|
||||
'total_stops_left': total_stops_left,
|
||||
'areas': areas,
|
||||
'routes': routes
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -42,27 +42,29 @@
|
|||
|
||||
{% block body %}
|
||||
<div class="header" >
|
||||
<h1>
|
||||
ChaloBEST! The Stats..
|
||||
<h1> ChaloBEST! The Stats..
|
||||
</h1>
|
||||
</div>
|
||||
<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="stops"> <h2>Total Stops : {{ total_stop_count }} <br /> Stops left : {{ total_stops_left }}</h2> <br /> <br />
|
||||
</div>
|
||||
|
||||
<div class="routes"> <h3> Routes: </h3><br />
|
||||
<ul id="routesList">
|
||||
{% for r in routes %}
|
||||
<li class="route listItem">
|
||||
<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 }}.
|
||||
<a href="{{r.route.get_absolute_url}}" title="view stops for route"> {{ r.route.alias }} </a>
|
||||
- {{ r.stops_done }} / {{ r.total_stops }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="areas"> <h3> Areas needing some love.. </h3> <br />
|
||||
<div class="areas"> <h3> Areas: </h3> <br />
|
||||
<ul id="AreasList">
|
||||
{% for a in areas %}
|
||||
<li class="area listItem">
|
||||
<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 }}.
|
||||
<a href="{{a.area.get_absolute_url}}" title="view stops for area">{{ a.area.name }}</a> - {{ a.stops_done }} / {{ a.total_stops }}.
|
||||
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
@ -51,4 +51,3 @@ def stats(request):
|
|||
|
||||
#return ret
|
||||
return render_to_response('stats.html', ret)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user