fix_missing data code tweaks

This commit is contained in:
Johnson Chetty 2012-06-08 10:47:48 +02:00
parent c19d3b1edf
commit cb02ccceac

View File

@ -5,7 +5,7 @@ import pdb
def fix_distances(): def fix_distances():
for unique_route in UniqueRoute.objects.all(): for unique_route in UniqueRoute.objects.all():
# RouteDetail sometimes isn't in order from from_stop to to_stop # RouteDetail sometimes isn't in order from from_stop to to_stop
from_stop, to_stop = unique_route.from_stop.id, unique_route.to_stop.id from_stop, to_stop = unique_route.from_stop, unique_route.to_stop
details = list(unique_route.route.routedetail_set.all()) details = list(unique_route.route.routedetail_set.all())
# Sometimes to_stop comes before from_stop in RouteDetail. What is there to say. # Sometimes to_stop comes before from_stop in RouteDetail. What is there to say.
# so reverse the list if that happens.. so a from_stop will always come before a to_stop # so reverse the list if that happens.. so a from_stop will always come before a to_stop
@ -36,7 +36,7 @@ def fix_distances():
if not last_stop_passed: if not last_stop_passed:
# add it # add it
if detail.km: if detail.km:
distance += float(detail.km) distance += float(detail.km)
else: else:
# if stage having km info reached after last stop, then add and exit loop # if stage having km info reached after last stop, then add and exit loop
if detail.km: if detail.km: