merged
This commit is contained in:
commit
ba4f482a2b
|
@ -202,8 +202,6 @@ def getserial(rdlist,stop):
|
|||
# write ring specific code here. rings have multiple occuring stops, which one to choose??
|
||||
return None
|
||||
|
||||
|
||||
|
||||
for rd in rdlist:
|
||||
if(rd.stop==stop):
|
||||
return rdlist.index(rd)
|
||||
|
@ -215,14 +213,30 @@ 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)]
|
||||
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,29 @@ 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)
|
||||
return render_to_response("stats.html", {
|
||||
|
||||
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
|
||||
routes.reverse()
|
||||
areas.reverse()
|
||||
|
||||
context = {
|
||||
'total_stop_count': total_stops,
|
||||
'total_stops_left': total_stops_left,
|
||||
'areas': areas,
|
||||
'routes': routes
|
||||
})
|
||||
}
|
||||
#return context
|
||||
return render_to_response("stats.html", context)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<meta http-equiv="refresh" content="45">
|
||||
<meta http-equiv="refresh" content="60">
|
||||
|
||||
<style type ="text/css">
|
||||
body {
|
||||
width: 80%;
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
background-color:#ff9900
|
||||
}
|
||||
|
@ -29,9 +29,29 @@
|
|||
|
||||
.areas {
|
||||
color:#000000;
|
||||
background-color:#00ccff;
|
||||
background-color:#ccff99;
|
||||
}
|
||||
|
||||
ul{
|
||||
width:900px;
|
||||
margin-bottom:20px;
|
||||
overflow:hidden;
|
||||
border-top:1px solid #ccc;
|
||||
|
||||
}
|
||||
|
||||
li{
|
||||
line-height:1.5em;
|
||||
/*border-bottom:1px solid #ccc; */
|
||||
float:left;
|
||||
display:inline;
|
||||
|
||||
}
|
||||
.double li { width:50%;} /* 2 col */
|
||||
.triple li { width:33.333%; } /* 3 col */
|
||||
.quad li { width:25%; } /* 4 col */
|
||||
.six li { width:16.666%; } /*
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
@ -42,27 +62,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="stops"> <h2>Total Stops : {{ total_stop_count }} <br /> Stops left : {{ total_stops_left }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="routes"> <h3> Routes needing some love.. </h3><br />
|
||||
<ul id="routesList">
|
||||
<div class="routes"> <h3> Routes: </h3><br />
|
||||
<ul id="routesList" class="six" >
|
||||
{% 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 }}.
|
||||
<li class="route listItem" >
|
||||
<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 />
|
||||
<ul id="AreasList">
|
||||
<div class="areas"> <h3> Areas: </h3> <br />
|
||||
<ul id="AreasList" class="quad" >
|
||||
{% 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>
|
||||
|
|
|
@ -11,44 +11,3 @@ def index(request):
|
|||
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.point:
|
||||
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)
|
||||
astops_left = Stop.objects.filter(area=area).filter(point=None).count()
|
||||
# for stp in area_stops:
|
||||
# if stp.point:
|
||||
# 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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user