Skip to content

fix(ratewise): RW-6 moneybox 首爾掛牌日跨日刷新(#514 拆分 6/7)#520

Closed
s123104 wants to merge 2 commits into
mainfrom
rw-6-moneybox-cross-day
Closed

fix(ratewise): RW-6 moneybox 首爾掛牌日跨日刷新(#514 拆分 6/7)#520
s123104 wants to merge 2 commits into
mainfrom
rw-6-moneybox-cross-day

Conversation

@s123104

@s123104 s123104 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

摘要

#514 拆分第 6 支(獨立、零視覺風險)。換錢所(MoneyBox)匯率以首爾掛牌日為準,但牌價不變卻跨日時,latest.json 未刷新 → 與每日 history 日期不對齊,趨勢圖天數/日期可能不準。

變更

  • scripts/fetch-moneybox-rates.js:新增 extractSeoulSnapshotDate(updateTime 首爾日曆 / UTC timestamp 換算)+ shouldRefreshLatestSnapshotrate-changed 或 date-rollover 才刷新),整合進 hasRateChanges
  • 紅線保留needsSchemaMigration / enrichExchangeShopRatesPayload(schema 遷移)完全不動,新邏輯疊加非取代
  • scripts/__tests__/fetch-moneybox-rates.test.ts(新):date-rollover / unchanged / rate-changed 三案例,並納入 test:root

範圍說明

  • workflow history 檔名(首爾日)與 SW history-30d.json 離線快取路由列 RW-6b(避免本支過大)。

Test plan

  • moneybox vitest 3 passed
  • 腳本 import 5 exports 正常(含保留的 needsSchemaMigration)
  • main() import.meta guard 確認測試不觸發 fetch

Refs #514(6/7)。獨立可合。

🤖 Generated with Claude Code
via Happy

- 加 extractSeoulSnapshotDate/shouldRefreshLatestSnapshot:rate-changed 或 date-rollover 才刷新
- 整合進 hasRateChanges;保留 main 的 needsSchemaMigration/enrichExchangeShop(紅線不取代)
- 補 3 個 vitest 案例並納入 test:root(date-rollover/unchanged/rate-changed)

測試:moneybox vitest 3 passed、腳本 import 5 exports 正常、needsSchemaMigration 保留

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1568401338

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +261 to +264
if (oldSnapshotDate && newSnapshotDate && oldSnapshotDate !== newSnapshotDate) {
return {
shouldUpdate: true,
reason: 'date-rollover',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Align rollover refresh with the history file date

When a scheduled run lands after Seoul midnight but before Taipei midnight (15:00–15:59 UTC), this new date-rollover path marks latest.json dirty even if rates are unchanged; I checked .github/workflows/update-moneybox-rates.yml, and the save-history step still computes CURRENT_DATE with TZ=Asia/Taipei and copies the current fetch whenever latest is dirty. That means a Seoul 2026-06-01 snapshot can be written to providers/moneybox/history/2026-05-31.json, corrupting the public daily history and history-30d dates; please derive the history filename from the Seoul snapshot date or hold this rollover update until the workflow uses the same date basis.

Useful? React with 👍 / 👎.

- workflow history 檔名改用 extractSeoulSnapshotDate(資料首爾掛牌日)+ fallback 首爾 wall-clock
- aggregate 首次缺失補 changed=true,避免 history-30d.json 遺失卻不開 PR
- sw.ts history-30d 路由加 providers/moneybox 路徑,離線可服務換錢所趨勢圖

測試:typecheck、lint、test 2516 passed、build:ratewise(sw 編進 worker)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@s123104

s123104 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

已加入 RW-6b(本 PR 現為完整 MoneyBox 收尾):① workflow history 檔名改用首爾掛牌日(extractSeoulSnapshotDate + fallback)② aggregate 缺失補 changed=true ③ sw.ts history-30d 路由加 providers/moneybox(離線趨勢圖)。typecheck/lint/2516 測試/build 全綠。

@github-actions

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b43012454a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ratewise/src/sw.ts
registerRoute(
({ url }: { url: URL }) =>
url.pathname.includes('/public/rates/history-30d.json') ||
url.pathname.includes('/public/rates/providers/moneybox/history-30d.json') ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 保留兩個 history aggregate 快取項目

這裡把 MoneyBox aggregate 加進既有的 history-aggregate-cache,但同一個 route 下面的 ExpirationPlugin 仍是 maxEntries: 1;當使用者在線先載入台銀 /public/rates/history-30d.json 再載入 MoneyBox /providers/moneybox/history-30d.json(或反過來)時,後載入的項目會把前一個 aggregate 從同一個 Cache Storage 驅逐,離線切回另一種趨勢圖就沒有 aggregate 可用。請把容量調到至少 2 或拆成不同 cache,否則新增的離線趨勢快取只會保留最後載入的 provider。

Useful? React with 👍 / 👎.

@s123104

s123104 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

內容已 squash 合併至 #523(08e27f43),關閉重複 PR。

@s123104 s123104 closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant