AOSSIE-Org / AOSSIE-Org/DebateAI

[Bug Report] Debate Outcome Not Persisted for Debate vs Bot

Đang mở
#228 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
84
Fork
198
Merge trung bình
2 ngày 19 giờ
Pull request đã merge (30 ngày)
30

Mô tả

## 📌 Summary
Debate outcomes for **Debate vs Bot** sessions are not being persisted in the database due to an identifier mismatch between the database schema and the update query. This causes silent failures where debate results (win/loss/draw) are never saved, breaking downstream logic such as Elo updates, analytics, and user performance tracking.

---

## 🧩 Affected Components
- **Database Layer:** `backend/db/db.go`
- **Controller:** `backend/controllers/debatevsbot_controller.go`
- **Feature Area:** Debate vs Bot → Judging & Outcome Persistence

---

## 🔍 Root Cause Analysis
The database update function filters by `userId`, while the underlying MongoDB model stores `email`. The controller passes an email string to the update function, resulting in zero documents matched and no errors surfaced.

---

However:

- The DebateVsBot MongoDB model does not store userId
- It stores the user's email instead
- The controller passes an email string to this function

- This results in:

- MongoDB update query matching zero documents
- No error returned
- Silent failure

---

## ❌ Expected Behavior

- When a Debate vs Bot session is judged:
- The corresponding debate record should be updated with the correct outcome
- The update should target the correct debate document

---

## ✅ Actual Behavior

- No document is matched
- Debate outcome is never updated
- Application behaves as if the update succeeded

---

## 🧪 Steps to Reproduce

- Start a Debate vs Bot session
- Complete the debate and trigger judging
- Check the debate_vs_bot collection in MongoDB
- Observe that the outcome field remains unchanged or missing

---

## 💥 Impact

- Breaks debate result persistence
- Corrupts user statistics
- Makes Elo calculation and performance analytics inaccurate
- Silent failure makes debugging difficult

I am willing to submit a PR.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.