Loading forecast_app/app.py +12 −1 Original line number Diff line number Diff line Loading @@ -276,9 +276,20 @@ def predict(): # Get last 12 months as reference last_year = training_data['historical_data'][-12:] # Calculate averages for Year 10 for each watch year10_averages = {} for watch in watches: watch_id = watch['id'] total_demand = sum( month['watches'][watch_id - 1]['demand'] for month in last_year ) year10_averages[watch_id] = round(total_demand / 12) return render_template('predict.html', watches=watches, last_year=last_year) last_year=last_year, year10_averages=year10_averages) @app.route('/results') Loading forecast_app/templates/predict.html +1 −3 Original line number Diff line number Diff line Loading @@ -41,9 +41,7 @@ <tr class="has-background-light"> <td><strong>Average</strong></td> {% for watch in watches %} {% set watch_id = watch.id %} {% set avg = (last_year | map(attribute='watches') | map('selectattr', 'watch_id', 'equalto', watch_id) | list | map(attribute='0') | map(attribute='demand') | sum / 12) | round(0) | int %} <td class="has-text-right"><strong>{{ avg }} units</strong></td> <td class="has-text-right"><strong>{{ year10_averages[watch.id] }} units</strong></td> {% endfor %} </tr> </tbody> Loading Loading
forecast_app/app.py +12 −1 Original line number Diff line number Diff line Loading @@ -276,9 +276,20 @@ def predict(): # Get last 12 months as reference last_year = training_data['historical_data'][-12:] # Calculate averages for Year 10 for each watch year10_averages = {} for watch in watches: watch_id = watch['id'] total_demand = sum( month['watches'][watch_id - 1]['demand'] for month in last_year ) year10_averages[watch_id] = round(total_demand / 12) return render_template('predict.html', watches=watches, last_year=last_year) last_year=last_year, year10_averages=year10_averages) @app.route('/results') Loading
forecast_app/templates/predict.html +1 −3 Original line number Diff line number Diff line Loading @@ -41,9 +41,7 @@ <tr class="has-background-light"> <td><strong>Average</strong></td> {% for watch in watches %} {% set watch_id = watch.id %} {% set avg = (last_year | map(attribute='watches') | map('selectattr', 'watch_id', 'equalto', watch_id) | list | map(attribute='0') | map(attribute='demand') | sum / 12) | round(0) | int %} <td class="has-text-right"><strong>{{ avg }} units</strong></td> <td class="has-text-right"><strong>{{ year10_averages[watch.id] }} units</strong></td> {% endfor %} </tr> </tbody> Loading