first step for statistics
This commit is contained in:
		
							parent
							
								
									43e3f9c98b
								
							
						
					
					
						commit
						4ea42a7efd
					
				@ -17,94 +17,68 @@
 | 
				
			|||||||
                    <h3>{{vehicle.name}}</h3>
 | 
					                    <h3>{{vehicle.name}}</h3>
 | 
				
			||||||
                    <div class="table-responsive">
 | 
					                    <div class="table-responsive">
 | 
				
			||||||
                        <table class="table table-striped table-bordered table-condensed">
 | 
					                        <table class="table table-striped table-bordered table-condensed">
 | 
				
			||||||
							<tr>
 | 
					 | 
				
			||||||
								<th>Number of Pitstops:</th>
 | 
					 | 
				
			||||||
								<td>{{ vehicle.pitstop_count }}</td>
 | 
					 | 
				
			||||||
							</tr>
 | 
					 | 
				
			||||||
							<tr>
 | 
												<tr>
 | 
				
			||||||
								<th>Logged Distance:</th>
 | 
													<th>Logged Distance:</th>
 | 
				
			||||||
								<td>{{ vehicle.overall_distance | round(2) }} km</td>
 | 
													<td>{{ vehicle.overall_distance | round(2) }} km</td>
 | 
				
			||||||
							</tr>
 | 
												</tr>
 | 
				
			||||||
							<tr>
 | 
					 | 
				
			||||||
								<th>Average Distance:</th>
 | 
					 | 
				
			||||||
								<td>{{ vehicle.average_distance | round(2) }} km</td>
 | 
					 | 
				
			||||||
							</tr>
 | 
					 | 
				
			||||||
								<tr>
 | 
					 | 
				
			||||||
								<th>Litres fuelled:</th>
 | 
					 | 
				
			||||||
								<td>{{ vehicle.overall_litres | round(2) }} l</td>
 | 
					 | 
				
			||||||
							</tr>
 | 
					 | 
				
			||||||
							<tr>
 | 
					 | 
				
			||||||
								<th>Average Litres fuelled:</th>
 | 
					 | 
				
			||||||
								<td>{{ vehicle.average_litres_fuelled | round(2) }} l</td>
 | 
					 | 
				
			||||||
							</tr>
 | 
					 | 
				
			||||||
							<tr>
 | 
					 | 
				
			||||||
								<th>Average Litres used:</th>
 | 
					 | 
				
			||||||
								<td>{{ vehicle.average_litres_used | round(2) }} l/100km</td>
 | 
					 | 
				
			||||||
							</tr>
 | 
					 | 
				
			||||||
							<tr>
 | 
												<tr>
 | 
				
			||||||
								<th>Logged Costs:</th>
 | 
													<th>Logged Costs:</th>
 | 
				
			||||||
								<td>{{ vehicle.overall_costs | round(2) }} €</td>
 | 
													<td>{{ vehicle.overall_costs | round(2) }} €</td>
 | 
				
			||||||
							</tr>
 | 
												</tr>
 | 
				
			||||||
 | 
											</table>
 | 
				
			||||||
 | 
										</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<ul id="consumable_tabs" class="nav nav-tabs" data-tabs="tabs">
 | 
				
			||||||
 | 
					    {% for consumable in vehicle.consumables %}
 | 
				
			||||||
 | 
					        <li class="{% if loop.first %}active{% endif %}">
 | 
				
			||||||
 | 
					            <a href="#v{{vehicle.id}}_c{{consumable.id}}" id="i{{vehicle.id}}_c{{consumable.id}}" data-toggle="tab" >
 | 
				
			||||||
 | 
					                {{ consumable.name }}
 | 
				
			||||||
 | 
					            </a>
 | 
				
			||||||
 | 
					        </li>
 | 
				
			||||||
 | 
					    {% endfor %}
 | 
				
			||||||
 | 
					</ul>
 | 
				
			||||||
 | 
					<div id="consumable_tabs-content" class="tab-content">
 | 
				
			||||||
 | 
					    {% for consumable in vehicle.consumables %}
 | 
				
			||||||
 | 
					        <div class="tab-pane {% if loop.first %}active{% endif %}" id="v{{vehicle.id}}_c{{consumable.id}}">
 | 
				
			||||||
 | 
					            <table class="table table-striped table-bordered table-condensed">
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
								<th>Average Costs per Litre:</th>
 | 
					                    <th>Average Distance:</th>
 | 
				
			||||||
								<td>{{ vehicle.average_costs_per_litre | round(2) }} €/l</td>
 | 
					                    <td>{{ consumable.average_distance | round(2) }} km</td>
 | 
				
			||||||
 | 
					                </tr>
 | 
				
			||||||
 | 
					                <tr>
 | 
				
			||||||
 | 
					                    <th>Amount fuelled:</th>
 | 
				
			||||||
 | 
					                    <td>{{ consumable.amount | round(2) }} {{ consumable.unit }}</td>
 | 
				
			||||||
 | 
					                </tr>
 | 
				
			||||||
 | 
					                <tr>
 | 
				
			||||||
 | 
					                    <th>Average Amount fuelled:</th>
 | 
				
			||||||
 | 
					                    <td>{{ consumable.average_amount_fuelled | round(2) }} {{ consumable.unit }}</td>
 | 
				
			||||||
 | 
					                </tr>
 | 
				
			||||||
 | 
					                <tr>
 | 
				
			||||||
 | 
					                    <th>Average Amount used:</th>
 | 
				
			||||||
 | 
					                    <td>{{ consumable.average_amount_used | round(2) }} {{ consumable.unit }}/100km</td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
            </table>
 | 
					            </table>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
                    <ul id="charts_tabs" class="nav nav-tabs" data-tabs="tabs">
 | 
					    {% endfor %}
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<ul id="charts_tabs" class="nav nav-tabs" data-tabs="tabs">
 | 
				
			||||||
    <li class="active">
 | 
					    <li class="active">
 | 
				
			||||||
                            <a href="#v{{vehicle.id}}_c3" id="i{{vehicle.id}}_c3" data-toggle="tab">
 | 
					        <a href="#v{{vehicle.id}}_codometer" id="i{{vehicle.id}}_codometer" data-toggle="tab" >
 | 
				
			||||||
                                Consumption
 | 
					 | 
				
			||||||
                            </a>
 | 
					 | 
				
			||||||
                        </li>
 | 
					 | 
				
			||||||
                        <li>
 | 
					 | 
				
			||||||
                            <a href="#v{{vehicle.id}}_c1" id="i{{vehicle.id}}_c1" data-toggle="tab">
 | 
					 | 
				
			||||||
                                Fuelled litres
 | 
					 | 
				
			||||||
                            </a>
 | 
					 | 
				
			||||||
                        </li>
 | 
					 | 
				
			||||||
                        <li>
 | 
					 | 
				
			||||||
                            <a href="#v{{vehicle.id}}_c2" id="i{{vehicle.id}}_c2" data-toggle="tab">
 | 
					 | 
				
			||||||
            Odometer
 | 
					            Odometer
 | 
				
			||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
    </li>
 | 
					    </li>
 | 
				
			||||||
 | 
					    {% for consumable in vehicle.consumables %}
 | 
				
			||||||
        <li>
 | 
					        <li>
 | 
				
			||||||
                            <a href="#v{{vehicle.id}}_c4" id="i{{vehicle.id}}_c4" data-toggle="tab">
 | 
					            <a href="#v{{vehicle.id}}_c{{consumable.id}}_consumption" id="i{{vehicle.id}}_c{{consumable.id}}_consumption" data-toggle="tab" >
 | 
				
			||||||
                                Costs per litre
 | 
					                {{ consumable.name }} consumption
 | 
				
			||||||
            </a>
 | 
					            </a>
 | 
				
			||||||
        </li>
 | 
					        </li>
 | 
				
			||||||
                        <li>
 | 
					    {% endfor %}
 | 
				
			||||||
                            <a href="#v{{vehicle.id}}_c5" id="i{{vehicle.id}}_c5" data-toggle="tab">
 | 
					</ul>
 | 
				
			||||||
                                Costs
 | 
					<div id="charts_tabs-content" class="tab-content">
 | 
				
			||||||
                            </a>
 | 
					    <div class="tab-pane active" id="v{{vehicle.id}}_codometer">
 | 
				
			||||||
                        </li>
 | 
					        {% if vehicle.odometers|length > 0 %}
 | 
				
			||||||
                    </ul>
 | 
					 | 
				
			||||||
                    <div id="charts_tabs-content" class="tab-content">
 | 
					 | 
				
			||||||
                       <div class="tab-pane active" id="v{{vehicle.id}}_c3">
 | 
					 | 
				
			||||||
                            {% if vehicle.pitstop_count > 1 %}
 | 
					 | 
				
			||||||
    					        <div id="averageUsageDiv{{vehicle.id}}" style="width:100%; height:500px;"></div>
 | 
					 | 
				
			||||||
                                <script type="text/javascript">
 | 
					 | 
				
			||||||
                                    {{ chartScript('averageUsageDiv'+vehicle.id|str, vehicle.average_litres, 'l/100 km') }}
 | 
					 | 
				
			||||||
                                </script>
 | 
					 | 
				
			||||||
                            {% else %}
 | 
					 | 
				
			||||||
                                <div class="alert alert-warning" role="alert">
 | 
					 | 
				
			||||||
                                    not enough data: <a href="{{ url_for('select_consumable_for_new_pitstop', vid=vehicle.id) }}">log a pitstop</a>?
 | 
					 | 
				
			||||||
                                </div>
 | 
					 | 
				
			||||||
                            {% endif %}
 | 
					 | 
				
			||||||
                        </div>
 | 
					 | 
				
			||||||
                        <div class="tab-pane " id="v{{vehicle.id}}_c1">
 | 
					 | 
				
			||||||
                            {% if vehicle.pitstop_count > 0 %}
 | 
					 | 
				
			||||||
 					            <div id="fuelledChartDiv{{vehicle.id}}" style="width:100%; height:500px;"></div>
 | 
					 | 
				
			||||||
                                <script type="text/javascript">
 | 
					 | 
				
			||||||
                                    {{ chartScript('fuelledChartDiv'+vehicle.id|str, vehicle.litres, 'l') }}
 | 
					 | 
				
			||||||
                                </script>
 | 
					 | 
				
			||||||
                            {% else %}
 | 
					 | 
				
			||||||
                                <div class="alert alert-warning" role="alert">
 | 
					 | 
				
			||||||
                                    not enough data: <a href="{{ url_for('select_consumable_for_new_pitstop', vid=vehicle.id) }}">log a pitstop</a>?
 | 
					 | 
				
			||||||
                                </div>
 | 
					 | 
				
			||||||
                            {% endif %}
 | 
					 | 
				
			||||||
                        </div>
 | 
					 | 
				
			||||||
                        <div class="tab-pane " id="v{{vehicle.id}}_c2">
 | 
					 | 
				
			||||||
                            {% if vehicle.pitstop_count > 0 %}
 | 
					 | 
				
			||||||
            <div id="odometerChartDiv{{vehicle.id}}" style="width:100%; height:500px;"></div>
 | 
					            <div id="odometerChartDiv{{vehicle.id}}" style="width:100%; height:500px;"></div>
 | 
				
			||||||
            <script type="text/javascript">
 | 
					            <script type="text/javascript">
 | 
				
			||||||
                {{ chartScript('odometerChartDiv'+vehicle.id|str, vehicle.odometers, 'km') }}
 | 
					                {{ chartScript('odometerChartDiv'+vehicle.id|str, vehicle.odometers, 'km') }}
 | 
				
			||||||
@ -115,31 +89,22 @@
 | 
				
			|||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
        {% endif %}
 | 
					        {% endif %}
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
                        <div class="tab-pane " id="v{{vehicle.id}}_c4">
 | 
					    {% for consumable in vehicle.consumables %}
 | 
				
			||||||
                            {% if vehicle.pitstop_count > 0 %}
 | 
					        <div class="tab-pane active" id="v{{vehicle.id}}_c{{consumable.id}}_consumption">
 | 
				
			||||||
    					        <div id="costsPerLitre{{vehicle.id}}" style="width:100%; height:500px;"></div>
 | 
					            {% if consumable.average_amount|length > 0 %}
 | 
				
			||||||
 | 
					                <div id="consumptionChartDiv{{vehicle.id}}_c{{consumable.id}}" style="width:100%; height:500px;"></div>
 | 
				
			||||||
                <script type="text/javascript">
 | 
					                <script type="text/javascript">
 | 
				
			||||||
                                    {{ chartScript('costsPerLitre'+vehicle.id|str, vehicle.costsPerLitre, '€/l') }}
 | 
					                    {{ chartScript('consumptionChartDiv'+vehicle.id|str+'_c'+consumable.id|str, consumable.average_amount, consumable.unit+'/100km') }}
 | 
				
			||||||
                </script>
 | 
					                </script>
 | 
				
			||||||
            {% else %}
 | 
					            {% else %}
 | 
				
			||||||
                <div class="alert alert-warning" role="alert">
 | 
					                <div class="alert alert-warning" role="alert">
 | 
				
			||||||
                                    not enough data: <a href="{{ url_for('select_consumable_for_new_pitstop', vid=vehicle.id) }}">log a pitstop</a>?
 | 
					                    not enough data: <a href="{{ url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) }}">log a pitstop</a>?
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            {% endif %}
 | 
					            {% endif %}
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
                        <div class="tab-pane " id="v{{vehicle.id}}_c5">
 | 
					    {% endfor %}
 | 
				
			||||||
                            {% if vehicle.pitstop_count > 0 %}
 | 
					</div>
 | 
				
			||||||
    					        <div id="costs{{vehicle.id}}" style="width:100%; height:500px;"></div>
 | 
					
 | 
				
			||||||
                                <script type="text/javascript">
 | 
					 | 
				
			||||||
                                    {{ chartScript('costs'+vehicle.id|str, vehicle.costs, '€') }}
 | 
					 | 
				
			||||||
                                </script>
 | 
					 | 
				
			||||||
                            {% else %}
 | 
					 | 
				
			||||||
                                <div class="alert alert-warning" role="alert">
 | 
					 | 
				
			||||||
                                    not enough data: <a href="{{ url_for('select_consumable_for_new_pitstop', vid=vehicle.id) }}">log a pitstop</a>?
 | 
					 | 
				
			||||||
                                </div>
 | 
					 | 
				
			||||||
                            {% endif %}
 | 
					 | 
				
			||||||
                        </div>
 | 
					 | 
				
			||||||
                    </div>
 | 
					 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            {% endfor %}
 | 
					            {% endfor %}
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
@ -153,6 +118,18 @@
 | 
				
			|||||||
                  $('a[href="' + window.location.hash + '"]').click()
 | 
					                  $('a[href="' + window.location.hash + '"]').click()
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
 | 
					        jQuery(document).ready(function ($) {
 | 
				
			||||||
 | 
					            $('#consumable_tabs').tab();
 | 
				
			||||||
 | 
					            if(window.location.hash != "") {
 | 
				
			||||||
 | 
					                  $('a[href="' + window.location.hash + '"]').click()
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					        jQuery(document).ready(function ($) {
 | 
				
			||||||
 | 
					            $('#charts_tabs').tab();
 | 
				
			||||||
 | 
					            if(window.location.hash != "") {
 | 
				
			||||||
 | 
					                  $('a[href="' + window.location.hash + '"]').click()
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    </script>
 | 
					    </script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -5,52 +5,85 @@ from dis import code_info
 | 
				
			|||||||
from rollerverbrauch.entities import \
 | 
					from rollerverbrauch.entities import \
 | 
				
			||||||
    Pitstop
 | 
					    Pitstop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ConsumableStats:
 | 
				
			||||||
 | 
					    def __init__(self, vehicle, consumable):
 | 
				
			||||||
 | 
					        self.name = consumable.name
 | 
				
			||||||
 | 
					        self.id = consumable.id
 | 
				
			||||||
 | 
					        self.unit = consumable.unit
 | 
				
			||||||
 | 
					        self.amount = 0
 | 
				
			||||||
 | 
					        self.average_distance = 0
 | 
				
			||||||
 | 
					        self.average_amount_fuelled = 0
 | 
				
			||||||
 | 
					        self.average_amount_used = 0
 | 
				
			||||||
 | 
					        self.average_amount = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        pitstops = [stop for stop in vehicle.pitstops if stop.consumable_id == consumable.id]
 | 
				
			||||||
 | 
					        pitstop_count = len(pitstops)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if pitstop_count > 0:
 | 
				
			||||||
 | 
					            for pitstop in pitstops:
 | 
				
			||||||
 | 
					                self.amount += pitstop.amount
 | 
				
			||||||
 | 
					            self.average_amount_fuelled = self.amount / pitstop_count
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if pitstop_count > 1:
 | 
				
			||||||
 | 
					            overall_distance = vehicle.pitstops[-1].odometer - vehicle.pitstops[0].odometer
 | 
				
			||||||
 | 
					            self.average_distance = overall_distance / (pitstop_count - 1)
 | 
				
			||||||
 | 
					            self.average_amount_used = 100 * (self.amount - pitstops[0].amount) / overall_distance
 | 
				
			||||||
 | 
					            for index in range(1, pitstop_count):
 | 
				
			||||||
 | 
					                last_ps = pitstops[index - 1]
 | 
				
			||||||
 | 
					                current_ps = pitstops[index]
 | 
				
			||||||
 | 
					                self.average_amount.append(
 | 
				
			||||||
 | 
					                    StatsEvent(
 | 
				
			||||||
 | 
					                        current_ps.date,
 | 
				
			||||||
 | 
					                        round(100 * current_ps.amount/(current_ps.odometer - last_ps.odometer), 2)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class VehicleStats:
 | 
					class VehicleStats:
 | 
				
			||||||
    def __init__(self, vehicle):
 | 
					    def __init__(self, vehicle):
 | 
				
			||||||
        self.name = vehicle.name
 | 
					        self.name = vehicle.name
 | 
				
			||||||
        self.id = vehicle.id
 | 
					        self.id = vehicle.id
 | 
				
			||||||
        self.pitstop_count = len(vehicle.pitstops)
 | 
					 | 
				
			||||||
        self.overall_distance = 0
 | 
					        self.overall_distance = 0
 | 
				
			||||||
        self.average_distance = 0
 | 
					 | 
				
			||||||
        self.overall_litres = 0
 | 
					 | 
				
			||||||
        self.average_litres_fuelled = 0
 | 
					 | 
				
			||||||
        self.average_litres_used = 0
 | 
					 | 
				
			||||||
        self.litres = []
 | 
					 | 
				
			||||||
        self.average_litres = []
 | 
					 | 
				
			||||||
        self.odometers = []
 | 
					 | 
				
			||||||
        self.costsPerLitre = []
 | 
					 | 
				
			||||||
        self.costs = []
 | 
					 | 
				
			||||||
        self.overall_costs = 0
 | 
					        self.overall_costs = 0
 | 
				
			||||||
        self.average_costs_per_litre = 0
 | 
					        self.consumables = []
 | 
				
			||||||
        cost_count = 0;
 | 
					        self.odometers = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if self.pitstop_count > 0:
 | 
					        for consumable in vehicle.consumables:
 | 
				
			||||||
 | 
					            self.consumables.append(ConsumableStats(vehicle, consumable))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#        self.overall_litres = 0
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#        self.litres = []
 | 
				
			||||||
 | 
					#        self.average_litres = []
 | 
				
			||||||
 | 
					#        self.costsPerLitre = []
 | 
				
			||||||
 | 
					#        self.costs = []
 | 
				
			||||||
 | 
					#        self.average_costs_per_litre = 0
 | 
				
			||||||
 | 
					        # cost_count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        pitstop_count = len(vehicle.pitstops)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if pitstop_count > 0:
 | 
				
			||||||
             for pitstop in vehicle.pitstops:
 | 
					             for pitstop in vehicle.pitstops:
 | 
				
			||||||
                self.overall_litres += pitstop.litres
 | 
					        #         self.overall_litres += pitstop.amount
 | 
				
			||||||
                self.litres.append(StatsEvent(pitstop.date, pitstop.litres))
 | 
					        #         self.litres.append(StatsEvent(pitstop.date, pitstop.amount))
 | 
				
			||||||
                 self.odometers.append(StatsEvent(pitstop.date, pitstop.odometer))
 | 
					                 self.odometers.append(StatsEvent(pitstop.date, pitstop.odometer))
 | 
				
			||||||
                self.costsPerLitre.append(StatsEvent(pitstop.date, pitstop.costs / pitstop.litres))
 | 
					        #         self.costsPerLitre.append(StatsEvent(pitstop.date, pitstop.costs / pitstop.amount))
 | 
				
			||||||
                self.costs.append(StatsEvent(pitstop.date, pitstop.costs))
 | 
					        #         self.costs.append(StatsEvent(pitstop.date, pitstop.costs))
 | 
				
			||||||
                 self.overall_costs += pitstop.costs
 | 
					                 self.overall_costs += pitstop.costs
 | 
				
			||||||
                self.average_costs_per_litre += (pitstop.costs / pitstop.litres)
 | 
					        #         self.average_costs_per_litre += (pitstop.costs / pitstop.amount)
 | 
				
			||||||
                if pitstop.costs > 0:
 | 
					        #         if pitstop.costs > 0:
 | 
				
			||||||
                    cost_count += 1
 | 
					        #             cost_count += 1
 | 
				
			||||||
            self.average_litres_fuelled = self.overall_litres / self.pitstop_count
 | 
					        #     if cost_count > 0:
 | 
				
			||||||
            if cost_count > 0:
 | 
					        #         self.average_costs_per_litre = self.average_costs_per_litre / cost_count
 | 
				
			||||||
                self.average_costs_per_litre = self.average_costs_per_litre / cost_count
 | 
					        #     else:
 | 
				
			||||||
            else:
 | 
					        #         self.average_costs_per_litre = 0
 | 
				
			||||||
                self.average_costs_per_litre = 0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if self.pitstop_count > 1:
 | 
					        if pitstop_count > 1:
 | 
				
			||||||
            self.overall_distance = vehicle.pitstops[-1].odometer - vehicle.pitstops[0].odometer
 | 
					            self.overall_distance = vehicle.pitstops[-1].odometer - vehicle.pitstops[0].odometer
 | 
				
			||||||
            self.average_distance = self.overall_distance / (self.pitstop_count - 1)
 | 
					            # for index in range(1, self.pitstop_count):
 | 
				
			||||||
            self.average_litres_used = 100 * (self.overall_litres - vehicle.pitstops[0].litres) / self.overall_distance
 | 
					            #     last_ps = vehicle.pitstops[index - 1]
 | 
				
			||||||
            for index in range(1, self.pitstop_count):
 | 
					            #     current_ps = vehicle.pitstops[index]
 | 
				
			||||||
                last_ps = vehicle.pitstops[index - 1]
 | 
					            #     self.average_litres.append(StatsEvent(
 | 
				
			||||||
                current_ps = vehicle.pitstops[index]
 | 
					            #         current_ps.date,
 | 
				
			||||||
                self.average_litres.append(StatsEvent(
 | 
					            #         round(100 * current_ps.litres/(current_ps.odometer - last_ps.odometer), 2)))
 | 
				
			||||||
                    current_ps.date,
 | 
					 | 
				
			||||||
                    round(100 * current_ps.litres/(current_ps.odometer - last_ps.odometer), 2)))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class StatsEvent:
 | 
					class StatsEvent:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user