You need to sign in or sign up before continuing.
fix: the volunteer exit attendence
Merge Request
Overview
This MR updates the volunteer camp status tracking to include an "exited" state. It enables the system to correctly identify and report when a volunteer has completed their shift by checking for the presence of a logout timestamp.
What does this MR do and why?
Previously, the volunteer dashboard could only track if a user was signed up or attended. With this change, we now support a third state: Exited. This allows the frontend to show a "Thank You" screen instead of the QR scanner once a volunteer's attendance has been marked with a logout flag by an administrator.
Changes Made
-
Modified
app/schemas/medical_camp.py: Addedis_exited: boolto theVolunteerCampStatusPydantic model. -
Modified
app/services/medical_camp_service.py: Updatedget_volunteer_camp_statusto determineis_exitedstatus by checking forlogout_timein existing camp visits. -
Modified
tests/schemas/test_medical_camp_schema.py: Added unit test for the updated status schema. -
Modified
tests/test_services/test_medical_camp_service.py: Added unit test for the service logic to ensure correct status derivation.
Technical Details
-
Logic: A volunteer is considered "exited" if there is an active
CampVisitrecord for the current camp that has a non-nulllogout_time. -
Backward Compatibility:
is_exiteddefaults toFalsein the schema to ensure no breaking changes for existing consumers.
Type of Change
-
🐛 Bug fix (non-breaking change that fixes an issue) -
✨ New feature (non-breaking change that adds functionality) -
💥 Breaking change (fix or feature that would cause existing functionality to change) -
📝 Documentation update -
♻ ️ Refactor (no functional changes) -
⚡ Performance improvement -
🧪 Test update -
🔧 Configuration change -
🚨 Security fix -
🗑 ️ Deprecation (removing deprecated code)
Related Issues / References
closes #118
- Related to the frontend implementation of the Volunteer "Thank You" screen.
Screenshots or Screen Recordings
N/A - Backend logic change verified by unit tests.
How to Validate Locally
- Setup: Ensure the backend is running and the database is migrated.
-
Action: Create a
CampVisitfor a user and set alogout_time. -
Verification: Call the GET
/api/v1/medical-camps/volunteer/signup-statusendpoint. -
Expected Result: The response should include
"is_exited": true.
Testing Done
-
Unit tests added/updated -
API endpoint logic passing unit tests
Test Cases Covered:
| Scenario | Expected Result | Status |
|---|---|---|
| Volunteer has not logged out |
is_exited is false
|
|
| Volunteer has a logout timestamp |
is_exited is true
|
|
| Status schema validation | Schema accepts is_exited
|
Test Commands Run:
# Run service tests
pytest tests/test_services/test_medical_camp_service.py
# Run schema tests
pytest tests/schemas/test_medical_camp_schema.py
Code Quality Checklist
Code Standards
-
Code follows project conventions (naming, structure, formatting) -
No debug statements or commented-out code left -
No unused imports, variables, or functions -
No duplicate code -
Type hints are properly defined -
Ruff checks pass
Python & FastAPI Best Practices
-
Functions follow single-responsibility principle -
Async/await used correctly -
Pydantic models used for request/response validation -
Error handling is comprehensive
API Design
-
RESTful conventions followed -
Proper HTTP status codes returned -
Input validation implemented -
API documentation (docstrings) updated
Database & Migrations
-
No raw SQL queries (using SQLAlchemy ORM) -
Data integrity constraints maintained
Security
-
No sensitive data logged -
SQL injection prevention verified (ORM used)
Error Handling
-
Errors are caught and handled gracefully -
User-friendly error messages returned
Documentation
-
API documentation updated (docstrings, OpenAPI specs) -
Code comments explain complex logic
Known Limitations / Technical Debt
None.
Additional Notes
None.
MR Acceptance Checklist
Quality & Correctness
-
Code works as intended and solves the stated problem -
No bugs introduced -
Edge cases handled appropriately
Maintainability
-
Code is readable and well-organized -
Code is testable and well-tested -
Follows project patterns and conventions
Edited by Vandana reddy Balannagari