feat(S): admin 評分可見性——司機列表評價欄+訂單詳情該趟評分 - #47
Merged
Conversation
B5 上線後評分只有司機自己看得到,admin 端 grep -i rating 零命中: 營運方看不到任何司機的評價。乘客評了一個爛司機,客服與營運完全無感—— 這是「資料寫進去了,但該用它做決策的人看不到」,與 B5 當初替司機補上 「服務評價」是同一個問題的上一層。 - RideRatingRepository.SummaryByDrivers:一條 GROUP BY 取代逐列查詢。 司機列表動輒數十列,每列各打一次 SummaryByDriver 就是 N+1。 回傳的 map 只含有評分的司機,沒評分者由呼叫端以零值呈現。 - GET /admin/drivers 改回 adminDriverView(內嵌 *model.Driver 讓 JSON 攤平, 既有欄位一個不少)+ rating_avg/rating_count。 沒評分的司機一律回 (0, 0) 而非省略欄位——前端據 rating_count 判斷要顯示 「尚無評分」還是分數,缺鍵會讓它多判一種 undefined。 評分查失敗不擋司機列表(那是營運每天在用的主畫面)。 - GET /admin/rides/:id 加 rating(未評分時整個鍵不出現,與乘客端 CustomerRideView.rating 同一約定);讀取失敗同樣不擋詳情頁。 - 注入走可選的 SetRatings,未注入時兩處回應形狀不變。 驗收:go build/vet/gofmt 乾淨;新增 TestRatingSummaryByDrivers(真 PostGIS, 含「沒評分的司機不出現在 map 裡」與「批次結果與逐列一致」)。 docker compose 實打:司機 1 = 4.5/2 則((5+4)/2)、司機 2 = 0/0; 訂單詳情帶 rating(含空評論那筆),未評分的訂單無 rating 鍵。 admin 端對應:line-fleet-admin 同批。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
為什麼
B5 上線後,評分只有司機自己看得到。admin 端
grep -i rating零命中——營運方看不到任何司機的評價。乘客評了一個爛司機,客服與營運完全無感。
這與 B5 當初替司機補上「服務評價」是同一個問題的上一層:資料寫進去了,但該用它做決策的人看不到。
改了什麼
RideRatingRepository.SummaryByDrivers:一條GROUP BY取代逐列查詢。司機列表動輒數十列,每列各打一次
SummaryByDriver就是 N+1。回傳的 map 只含有評分的司機,沒評分者由呼叫端以零值呈現。
GET /admin/drivers改回adminDriverView(內嵌*model.Driver讓 JSON 攤平,既有欄位一個不少)+
rating_avg/rating_count。(0, 0)而非省略欄位:前端據rating_count判斷要顯示「尚無評分」還是分數,缺鍵會讓它多判一種 undefined。
GET /admin/rides/:id加rating(未評分時整個鍵不出現,與乘客端CustomerRideView.rating同一約定);讀取失敗同樣不擋詳情頁。SetRatings,未注入時兩處回應形狀不變。驗收
go build/go vet/gofmt乾淨。TestRatingSummaryByDrivers(真 PostGIS):含「沒評分的司機不出現在 map 裡」、「批次結果與逐列
SummaryByDriver一致」(批次是為了效能,不是為了不同的答案)、空清單不爆。/admin/drivers→ 司機 1rating_avg=4.5 rating_count=2((5+4)/2 ✓)、司機 2
rating_avg=0 rating_count=0。/admin/rides/1→rating含 score 5 與評論;/admin/rides/2→ 空評論那筆;/admin/rides/3(未評分)→ 無rating鍵。admin 端對應:thothawei/fleet-frontEnd(同批)
🤖 Generated with Claude Code