Skip to content

feat(weather): rank observations at any snapshot time - #647

Open
whes1015 wants to merge 1 commit into
mainfrom
feat/weather-ranking-snapshot-time
Open

whes1015 wants to merge 1 commit into
mainfrom
feat/weather-ranking-snapshot-time

Conversation

@whes1015

@whes1015 whes1015 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

這個 PR 做了什麼

觀測排行原本永遠只排「最新」那一刻的資料:資料時間是唯讀的,也沒有任何入口能回到過去,溫度極值則另外佔一個分頁。這個 PR 讓排行可以指定快照時間,並把溫度與溫度極值收進同一個分頁。

  • 選擇資料時間:AppBar 右上多一個時間按鈕,列出 /api/v5/meteor/{weather,rain}/list 回傳的快照時間(weather 每小時、約三天;rain 十分鐘),選了就改抓 /{sec} 歷史快照重新排名。選「最新」時仍走 latest(),下拉刷新維持即時;抓過的歷史快照依秒數快取,來回切換不再打網路。
  • 每一個資料集挑自己的最近快照:所選時間會各自落在該資料集「不晚於所選時間」的那一筆,所以雨量的 10 分鐘/1 小時/24 小時累積都是那個時間點記下的值,而不是天氣那一筆的時間。
  • 溫度與溫度極值合併:溫度分頁多一組 chip(當下/今日最高/今日最低/日溫差),極值照樣顯示發生時間。?tab=tempExtremes|high|low|range 的舊深連結仍然可用(開在溫度分頁並預選對應 chip),資料頁的「溫度極值」磚塊也留著,只是改開同一個分頁。
  • 風速、陣風、濕度、氣壓的當日極值沒有做:v5 快照只帶溫度的 hi/lo/hit/lot(陣風有 gt 發生時間),其餘欄位沒有極值;用每小時快照自行推算會低報(陣風尤其嚴重,整點取樣看不到 :30 的峰值),所以這部分需要後端先提供,不在這個 PR 裡用推算的數字充數。

改到的檔案:

  • 正式程式:lib/features/weather/presentation/pages/weather_ranking_page.dart(選時間、載入歷史、溫度分頁)、新增 lib/features/weather/presentation/widgets/ranking_time_sheet.dart(時間選擇器)、lib/features/weather/domain/weather_ranking.dart(TempRankMetric 與 rankTemperature)、lib/app/router/app_router.dart(?metric= 與舊 ?tab= 值)、12 個 lib/l10n/app_*.arb 與生成檔(新增 weatherRankingCurrent/Latest/PickTime,移除不再使用的 weatherRankingHighest/Lowest)。
  • 測試:test/features/weather/presentation/pages/weather_ranking_page_test.dart(假 repo 補上 history()/at(),新增四則:選歷史時間、回到最新、雨量落在自己的快照、沒有歷史時不顯示選擇器)、test/features/weather/domain/weather_ranking_test.dart(rankTemperature 的四個 metric)。

相關 issue

  • Discord 問題回報 ET-2026-0153(repo 裡沒有對應的 GitHub issue)

怎麼驗

  • tool/check.sh 全過(format/analyze、codegen 一致、每一道 shell gate、flutter test 3637 passed / 6 skipped)。
  • 時間選擇器的行為由 widget test 覆蓋:兩個 repo 各被問一次 at()、列表換成歷史數值、AppBar 不再寫「最新」、回到最新後不會再打 at()。
  • 尚未在實機或模擬器上看過 UI:這個環境沒有可用的 device。時間選擇器的版面(七十幾筆清單)、AppBar 上的時間標籤在窄螢幕會不會擠到標題,需要有人跑一次確認。

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
  • 一個 commit 一件事
  • flutter analyze 與 flutter test 通過
  • 新的使用者可見字串都走 AppLocalizations,沒有寫死
  • CI 全部通過(gh pr checks:build、Android、iOS、changes、code-review 全 pass)
  • 深色模式與窄螢幕的實機確認

Platform: all

New(zh-Hant): 觀測排行可以選擇資料時間,溫度分頁也能切換當下與當日極值
New(en-US): rankings can pick their data time, and the temperature tab switches between the reading and the day's extremes
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.33679% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.47%. Comparing base (fc8be25) to head (b56bfcd).

Files with missing lines Patch % Lines
...ather/presentation/pages/weather_ranking_page.dart 92.56% 9 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lowrt lowrt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants