feat: refine web analytics and history views

This commit is contained in:
Wyndham ARR
2026-08-02 12:56:22 +08:00
parent a891c0ae7a
commit 7e7470821b
37 changed files with 2088 additions and 361 deletions

View File

@@ -0,0 +1,35 @@
# Channel BI Copy and Data Coverage
## Metadata
- Date: 2026-07-31
- Status: Implemented
- Scope: Desktop Channel BI and H5 BI presentation plus additive analytics range fields
- Confidence: Fact
- Source: channel analytics contracts/provider, desktop and H5 static assets, focused tests
- Last verified: 2026-07-31
## User-Facing Outcome
- The BI-only CHANNEL PERFORMANCE eyebrow is removed from desktop and H5.
- The BI heading no longer shows the updated-through database snapshot copy.
- Visible BI TOTAL PRICE labels are removed; the revenue helper now reads 销售金额合计.
- 各公司本月销售情况 now has a small 数据范围:开始日期 结束日期 line immediately below its title on both surfaces.
## Data Contract
- The analytics endpoint continues to read current Finance facts in one repeatable-read, read-only snapshot.
- The response now adds min_arrival_date; the existing max_arrival_date remains the end of the coverage range.
- Both dates come from current daily-version business dates, which are validated to equal the included ARRIVAL dates. The
browser formats those API values by the active locale and never infers a full calendar month from the browser clock.
## Verification
- Desktop and H5 JavaScript syntax checks passed.
- Focused analytics/Web/UI tests passed, including the desktop/H5 copy contracts and min/max date API assertions.
- No Finance facts, monthly publication artifacts or report-generation behavior changed.
## Design Boundary
This is a preserve-mode refinement using the existing neutral/blue visual system. The range is intentionally a quiet
metadata line under the chart title so it clarifies the partial-month snapshot without competing with the sales ranking.

View File

@@ -0,0 +1,26 @@
# Channel BI header utilities
## Scope
This records the 2026-07-31 visual refinement of the ARR Web Channel BI page. The change is presentation-only and
does not alter analytics payloads, report generation, authentication endpoints or business data.
## Implemented
- Removed the visible `渠道BI` page heading from the desktop BI panel and H5 hero. The top navigation label and H5
document title remain available as context.
- Removed the ready-state `数据库已连接` wording. The desktop/H5 status indicator keeps its colored dot and an
accessible status label, while the unavailable state still exposes its visible warning copy.
- Reduced the `查看月份` control to a compact 92px/26px selector family on desktop and H5 so it reads as a quiet
utility rather than a competing page heading.
- Raised the desktop BI panel by 20px toward the four-tab bar after removing the page heading; the responsive
desktop shell uses a smaller 10px adjustment on narrow widths to retain breathing room.
- Replaced the desktop task-log and logout button chrome with focusable text links. Their event interception, dialog
opening, logout request and busy/error handling remain intact; H5 logout follows the same low-emphasis pattern.
## Verification
- `node --check arr_web/static/app.js`
- `node --check arr_web/static/h5.js`
- 21 focused BI, daily visual, task-log and auth tests passed.
- 18 `tests.test_arr_web` tests passed.

View File

@@ -0,0 +1,29 @@
# Evidence Topic: 2131 same-room-category multi-price warning
- Date: 2026-07-31
- Status: Active data-review finding; no code or database mutation
- Scope: Successful job `8aa1fdef3b644f3a9cc0f26924445a29`, July `21-month-end`
- Confidence: Fact
- Stale trigger: Finance-version change, report rerun, or pricing rule change
## Rule
For each output segment `(normalized Group Code, ARRIVAL, DEPARTURE)`, the processor groups Finance facts by
`(room_category_label, total_price)`. If one Finance room-category label has more than one distinct `total_price` in
that segment, it emits `COMPANY_REPORT_MULTI_PRICE_REVIEW` with stage `pricing` and keeps the report successful. It does
not use Booking Room or Markdown room types for this check, and it does not choose min/max/average on behalf of the user.
## Observed job
- Five companies succeeded; warnings were LianTai 4, QBD 8, DY-AI-Easy-KB 0, FengRun 1 and HanaTour 0.
- There were 13 warning groups covering 116 Finance record IDs.
- Representative LianTai case: Group Code `LT260718KB`, stay `2026-07-20 → 2026-07-22`; `RM3` appears at 3,600 for
nine records and 6,800 for one record. The output therefore keeps both terms, e.g. `【RM3】3,600×9 + 【RM3】6,800×1`.
- The Booking lookup for that same Group Code remains independent (`【DBL】12` in the current Markdown source).
## Interpretation
The warning means Finance/Opera contains a price inconsistency or a legitimate pricing split for the same Finance room
category within one output segment. It is a human-review signal, not a Booking matching failure and not a report error.
To resolve it, inspect the underlying Finance/Opera pricing rows and decide whether the differing prices are expected. If
the source is wrong, correct the Finance input and rerun; if expected, retain the warning as an audit note.

View File

@@ -0,0 +1,26 @@
# ARR Web 中英泰国际化实现
## 结论
2026-07-31 用户确认执行后ARR Web 展示层完成 `zh-CN``en``th` 三语切换基础实现。桌面 `/`、H5 `/h5` 和登录 `/login` 共用一个前端词典/runtime默认中文语言选择保存到 localStorage 与同源 cookie并同步 `html.lang`。顶部品牌 `ARR Report`、XML/Excel/Booking/Finance/BI/C/O、字段名、公司/渠道/房型和报告文件/worksheet 等专有名词保持原样或仅翻译其周边说明。
## 实施范围
- 新增 `arr_web/static/i18n.js`:语义词典、稳定 API 错误码映射、动态 DOM/属性翻译、分页/任务文本模式、日期/整数/CNY/耗时格式化;泰文格式强制 Gregorian calendar 与 Latin digits业务时区仍为 `Asia/Bangkok`
- `arr_web/static/index.html``h5.html``login.html` 增加语言选择器和 runtime`app.js``h5.js``login.js` 接入状态、Toast、确认/空态、错误、任务日志、无障碍属性及 locale-change 重绘。
- `styles.css``h5.css``login.css` 增加泰文字体回退和选择器样式;`arr_web/app.py` 将 i18n runtime 加入静态路由及匿名登录资源白名单。
## 边界与不变量
- 未触发上传、月报/公司报表生成、Booking 草稿删除/激活、下载或数据库写入未修改认证、CSRF、轮询和业务状态判断。
- 业务状态值、API 结构和报表 Excel 文件名、sheet、表头、公式契约保持不变语言只作用于用户展示层。API 错误继续通过 code 识别,前端按 locale 显示人类可见文案。
- 语言切换不把已翻译文本当作源文本runtime 保存原始文案,因此可以从英文/泰文切回中文。
## 验证
- `node --check arr_web/static/i18n.js arr_web/static/app.js arr_web/static/h5.js arr_web/static/login.js`:通过。
- Node DOM/runtime smoke中文 → English → ไทย → 中文恢复正常;`2026-07` 月份文案和 Thai/English locale 格式化通过;未知 API 错误在英文/泰文下回退到对应语言通用提示。
- `python3 -m unittest discover -s tests -p 'test_arr_web*.py'`61/61 通过。
- 当前源码临时预览的 390px 登录页验证中文、English、ไทย切换`ARR Report` 保持不变,泰文长文案无横向溢出。预览进程已关闭,未触碰共享 8766 服务或业务数据。
- 19:27:42 +08 按现有 Screen/Keychain launcher 重启共享 8766旧进程因未重启仍重定向 `/assets/i18n.js`,重启后 loopback 与当前 LAN `192.168.3.103``/login``/healthz``/assets/i18n.js` 分别返回 200匿名根路径返回登录重定向。原 `192.168.3.48` 已不在本机网卡上,未执行业务写操作。
- 完整 `python3 -m unittest discover -s tests`298 个测试中 8 个环境错误,均为既有测试环境缺少 `httpx` 或 OSS client 映射为 unavailable未出现与本次 Web 国际化改动相关的失败。

View File

@@ -0,0 +1,64 @@
# Cross-month history visibility
## Metadata
- Date: 2026-08-02
- Status: Implemented and runtime-active
- Scope: desktop daily history, monthly publications and company-channel job history
- Confidence: Verified implementation and runtime evidence
- Source: frontend/backend inspection, controlled read-only PostgreSQL queries, automated tests and isolated browser QA
- Business-data mutation: none
## Reported symptom
After the Bangkok business month advanced from July to August, users could no longer see the prior month's daily,
monthly or company-channel records from the default page state.
## Root-cause evidence
- `arr_web/static/app.js` makes both `loadJobs()` and `loadMonthly()` query `localMonth()` directly. Their history
panels expose pagination but no visible month control.
- The company page initializes `#company-report-month` to `localMonth()` and uses the same input for C/O generation
state/payload and history filtering. Its visible label is screen-reader-only and the control sits in the generation
setup panel, so its history-filter role is easy to miss.
- All three backend list contracts already accept a month. Daily rows are filtered by `business_date` with a
`created_at` fallback, monthly publications by `period_start`, and company jobs by `report_month`.
- A controlled repeatable-read query on 2026-08-02 found 30 daily jobs and four monthly publications for 2026-07,
versus zero and zero for 2026-08.
- Local company job state retains one 2026-06 job and four 2026-07 jobs; July contains three succeeded and one failed
job across all three C/O periods. June/July company workbooks and July monthly archives also remain on disk.
## Finding
This is a history-navigation/display-state defect, not evidence of data deletion. Entering a new month makes the
default frontend requests target an empty current month and provides no discoverable daily/monthly path back; the
company path exists but conflates generation scope with history scope.
## Implemented repair
- Added authenticated read-only `GET /api/history-months`. It merges daily/monthly counts from the guarded PostgreSQL
repository with company job-state counts and introduces no table, migration or report-data change.
- Added consistent previous/month/next/`本月` controls to Daily Report, monthly processing and company generation
history. Daily and monthly default independently to their latest non-empty month.
- Pagination and empty states name the selected month. Empty months expose a direct link to the latest month with that
record type.
- Split company `生成月份` from history `查看月份`; changing either one no longer changes the other. A newly submitted
company job moves only the history view to the submitted month.
- Monthly polling continues to read the selected viewing month. It is presentation state only and is never added to
the report-generation contract.
- Added Chinese, English and Thai copy and responsive wrapping/focus treatment.
## Acceptance results
- A direct guarded read-only repository call returns `2026-07` with 30 daily and four monthly records. Durable company
job state contributes four July and one June jobs; all three July histories therefore become the initial view while
the Bangkok current month is empty.
- `node --check`, Python compilation and `git diff --check` pass. The complete project discovery passes 356 tests with
10 environment-conditional skips.
- Isolated authenticated browser QA at 1440, 900 and 390 pixels found no document-level horizontal overflow. Tables
retain their intentional internal scroll on narrow screens.
- Chinese, English and Thai mobile controls remain within the 390-pixel viewport. Company history was changed from
July to empty August, exposed `查看 2026年7月`, and returned to four July rows while `生成月份` remained August.
- The production Web process on port 8766 was restarted under detached Screen after verification; `/healthz` returned
`ready`. The isolated QA service was stopped. No upload, source activation, report generation or business-data write
was performed.