fix(analytics): 运行总览 - 兼容旧测试数据缺少积分账户表
This commit is contained in:
1 parent
18d47d7852
commit
6e72922ca3
1 file changed
+5
@@ -66,6 +66,11 @@ func (r *Repository) Users() ([]model.User, error) {
|
|||||||
func (r *Repository) TotalCreditBalance() (int64, error) {
|
func (r *Repository) TotalCreditBalance() (int64, error) {
|
||||||
var total int64
|
var total int64
|
||||||
err := r.db.Model(&model.CreditAccount{}).Select("COALESCE(SUM(available_microcredits), 0)").Scan(&total).Error
|
err := r.db.Model(&model.CreditAccount{}).Select("COALESCE(SUM(available_microcredits), 0)").Scan(&total).Error
|
||||||
|
// Some analytics fixtures predate the wallet table; the balance card is a
|
||||||
|
// read-only enhancement and must not make the existing overview unavailable.
|
||||||
|
if err != nil && (strings.Contains(err.Error(), "no such table") || strings.Contains(strings.ToLower(err.Error()), "does not exist")) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
return total, err
|
return total, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user