Unverified Commit 9d66f4be authored by Utorque's avatar Utorque Committed by GitHub
Browse files

Merge pull request #2 from Utorque/claude/horloml-web-app-011CUbWgr7HjWM2LFKdsZCmc

Fix Jinja2 template error in predict.html
parents eb36de58 c6d4c7b5
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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')
+1 −3
Original line number Diff line number Diff line
@@ -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>