Commit ·
05de2bb
1
Parent(s): ef2d721
ホーム画面から「今後の客数予測(β)」セクションを削除
Browse files客数予測の表示は客数管理ページに集約し、ホーム画面はTODO中心の
シンプルな構成に戻す。
- routes/dashboard.py +2 -29
- templates/dashboard/index.html +0 -45
routes/dashboard.py
CHANGED
|
@@ -1,12 +1,9 @@
|
|
| 1 |
-
from datetime import date as _date
|
| 2 |
from collections import defaultdict
|
| 3 |
from flask import Blueprint, render_template, url_for
|
| 4 |
from db import repositories as repo
|
| 5 |
-
from optimizer import forecast as forecast_mod
|
| 6 |
from utils.constants import TimeSlot, Position
|
| 7 |
|
| 8 |
-
_FORECAST_DAYS = 7
|
| 9 |
-
|
| 10 |
bp = Blueprint("dashboard", __name__)
|
| 11 |
|
| 12 |
_DAY_JP = ['月', '火', '水', '木', '金', '土', '日']
|
|
@@ -32,7 +29,7 @@ def index():
|
|
| 32 |
upcoming_short_days = [] # 直近7日の不足日ラベル
|
| 33 |
unsubmitted = [] # 希望未提出スタッフ
|
| 34 |
todos = [] # TODOアイテム
|
| 35 |
-
res_counts = {} # 予約客数(
|
| 36 |
|
| 37 |
if not latest:
|
| 38 |
todos.append({
|
|
@@ -168,26 +165,6 @@ def index():
|
|
| 168 |
'url': url_for('customers.list_periods'),
|
| 169 |
})
|
| 170 |
|
| 171 |
-
# ── 客数予測(β):今後N日分のサマリー ──
|
| 172 |
-
forecast_enabled = repo.get_app_setting("customer_forecast_enabled", "0") == "1"
|
| 173 |
-
forecast_rows = []
|
| 174 |
-
if forecast_enabled:
|
| 175 |
-
fc_dates = [today + timedelta(days=i) for i in range(_FORECAST_DAYS)]
|
| 176 |
-
fc_strs = tuple(d.isoformat() for d in fc_dates)
|
| 177 |
-
special_days = tuple(sorted(
|
| 178 |
-
ds for ds, c in res_counts.items() if c.get("is_special_day") and ds in fc_strs
|
| 179 |
-
))
|
| 180 |
-
fc_data = forecast_mod.predict_customer_counts_cached(fc_strs, special_days)
|
| 181 |
-
thresh_b = int(repo.get_app_setting("reserv_threshold_breakfast", "100"))
|
| 182 |
-
thresh_d = int(repo.get_app_setting("reserv_threshold_dinner", "25"))
|
| 183 |
-
for d in fc_dates:
|
| 184 |
-
fc = fc_data.get(d.isoformat(), {})
|
| 185 |
-
forecast_rows.append({
|
| 186 |
-
'date': d,
|
| 187 |
-
'breakfast': fc.get('breakfast', {}),
|
| 188 |
-
'dinner': fc.get('dinner', {}),
|
| 189 |
-
})
|
| 190 |
-
|
| 191 |
return render_template(
|
| 192 |
'dashboard/index.html',
|
| 193 |
today=today,
|
|
@@ -201,8 +178,4 @@ def index():
|
|
| 201 |
upcoming_short_days=upcoming_short_days,
|
| 202 |
todos=todos,
|
| 203 |
DAY_JP=_DAY_JP,
|
| 204 |
-
forecast_enabled=forecast_enabled,
|
| 205 |
-
forecast_rows=forecast_rows,
|
| 206 |
-
thresh_b=thresh_b if forecast_enabled else 0,
|
| 207 |
-
thresh_d=thresh_d if forecast_enabled else 0,
|
| 208 |
)
|
|
|
|
| 1 |
+
from datetime import date as _date
|
| 2 |
from collections import defaultdict
|
| 3 |
from flask import Blueprint, render_template, url_for
|
| 4 |
from db import repositories as repo
|
|
|
|
| 5 |
from utils.constants import TimeSlot, Position
|
| 6 |
|
|
|
|
|
|
|
| 7 |
bp = Blueprint("dashboard", __name__)
|
| 8 |
|
| 9 |
_DAY_JP = ['月', '火', '水', '木', '金', '土', '日']
|
|
|
|
| 29 |
upcoming_short_days = [] # 直近7日の不足日ラベル
|
| 30 |
unsubmitted = [] # 希望未提出スタッフ
|
| 31 |
todos = [] # TODOアイテム
|
| 32 |
+
res_counts = {} # 予約客数(今日の予約客数表示用)
|
| 33 |
|
| 34 |
if not latest:
|
| 35 |
todos.append({
|
|
|
|
| 165 |
'url': url_for('customers.list_periods'),
|
| 166 |
})
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
return render_template(
|
| 169 |
'dashboard/index.html',
|
| 170 |
today=today,
|
|
|
|
| 178 |
upcoming_short_days=upcoming_short_days,
|
| 179 |
todos=todos,
|
| 180 |
DAY_JP=_DAY_JP,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
)
|
templates/dashboard/index.html
CHANGED
|
@@ -263,51 +263,6 @@
|
|
| 263 |
{% endif %}
|
| 264 |
</div>
|
| 265 |
|
| 266 |
-
{# ───────────── 1.5 客数予測(β) ───────────── #}
|
| 267 |
-
{% if forecast_enabled %}
|
| 268 |
-
<div class="section-label">今後の客数予測(β)</div>
|
| 269 |
-
<div class="db-card-dark">
|
| 270 |
-
<div class="table-responsive">
|
| 271 |
-
<table class="table table-sm table-borderless mb-0" style="color:#e2e8f0;font-size:.78rem">
|
| 272 |
-
<thead>
|
| 273 |
-
<tr style="color:#64748b;font-size:.7rem">
|
| 274 |
-
<th></th>
|
| 275 |
-
<th class="text-center"><i class="bi bi-sun" style="color:#f59e0b"></i> 朝食</th>
|
| 276 |
-
<th class="text-center"><i class="bi bi-moon" style="color:#818cf8"></i> ディナー</th>
|
| 277 |
-
</tr>
|
| 278 |
-
</thead>
|
| 279 |
-
<tbody>
|
| 280 |
-
{% for row in forecast_rows %}
|
| 281 |
-
{% set b = row.breakfast %}
|
| 282 |
-
{% set dn = row.dinner %}
|
| 283 |
-
<tr>
|
| 284 |
-
<td>
|
| 285 |
-
{{ row.date.strftime('%m/%d') }}
|
| 286 |
-
<small class="text-muted">({{ DAY_JP[row.date.weekday()] }})</small>
|
| 287 |
-
{% if loop.first %}<small class="text-muted">本日</small>{% endif %}
|
| 288 |
-
</td>
|
| 289 |
-
<td class="text-center">
|
| 290 |
-
{% if b.predicted is not none %}
|
| 291 |
-
<span style="font-weight:700;{{ 'color:#f87171' if (thresh_b > 0 and b.predicted >= thresh_b) else 'color:#e2e8f0' }}">{{ b.predicted }}名</span>
|
| 292 |
-
{% else %}<span class="text-muted">―</span>{% endif %}
|
| 293 |
-
</td>
|
| 294 |
-
<td class="text-center">
|
| 295 |
-
{% if dn.predicted is not none %}
|
| 296 |
-
<span style="font-weight:700;{{ 'color:#f87171' if (thresh_d > 0 and dn.predicted >= thresh_d) else 'color:#e2e8f0' }}">{{ dn.predicted }}名</span>
|
| 297 |
-
{% else %}<span class="text-muted">―</span>{% endif %}
|
| 298 |
-
</td>
|
| 299 |
-
</tr>
|
| 300 |
-
{% endfor %}
|
| 301 |
-
</tbody>
|
| 302 |
-
</table>
|
| 303 |
-
</div>
|
| 304 |
-
<div class="text-muted" style="font-size:.68rem;margin-top:.4rem">
|
| 305 |
-
過去の実績・曜日・気象などをもとにしたAI予測です。
|
| 306 |
-
<a href="{{ url_for('customers.list_periods') }}" style="color:#38bdf8">客数管理ページ</a>で実績を入力すると精度が向上します。
|
| 307 |
-
</div>
|
| 308 |
-
</div>
|
| 309 |
-
{% endif %}
|
| 310 |
-
|
| 311 |
{# ───────────── 2. TODOリスト ───────────── #}
|
| 312 |
<div class="section-label">TODO</div>
|
| 313 |
{% if todos %}
|
|
|
|
| 263 |
{% endif %}
|
| 264 |
</div>
|
| 265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
{# ───────────── 2. TODOリスト ───────────── #}
|
| 267 |
<div class="section-label">TODO</div>
|
| 268 |
{% if todos %}
|