Closed ricardogsilva closed 6 years ago
This PR implements most of the aggregation queries specified in #123
Still missing are those queries that deal with hour ranges. These are a bit more involved and perhaps will need the addition of extra DB fields.
Main code is in tracks.utils. Some examples ran with the test data introduced by the populatetracks and populatesegments commands:
tracks.utils
populatetracks
populatesegments
>>> get_aggregated_data("emissions") {'so2': 4.93744534990608, 'so2_saved': 7.72889478477773, 'nox': 7227.74670426025, 'nox_saved': 3232.08327363432, 'co2': 749.593975849378, 'co2_saved': 1243.6494335506, 'co': 1628.23481879858, 'co_saved': 4335.20734746169, 'pm10': 306.346041028264, 'pm10_saved': 323.208327363432} >>> list(get_annotated_costs(annotate_by=["vehicle_type"]) [{'vehicle_type': 'bike', 'fuel_cost': 0.0, 'time_cost': 56.6355555555556, 'depreciation_cost': 0.0, 'operation_cost': 0.0, 'total_cost': 56.6355555555556}, {'vehicle_type': 'bus', 'fuel_cost': 3.3664400112996, 'time_cost': 1.90888888888889, 'depreciation_cost': 0.0, 'operation_cost': 0.0, 'total_cost': 5.27532890018849}]
The tracks.utils module docstring contains more example usages, one for each requested aggregation query in the #123 issue description.
connected to #123
This PR implements most of the aggregation queries specified in #123
Still missing are those queries that deal with hour ranges. These are a bit more involved and perhaps will need the addition of extra DB fields.
Main code is in
tracks.utils
. Some examples ran with the test data introduced by thepopulatetracks
andpopulatesegments
commands:The
tracks.utils
module docstring contains more example usages, one for each requested aggregation query in the #123 issue description.connected to #123