Skip to content

fix: the volunteer exit attendence

Vandana reddy Balannagari requested to merge fix/exit into develop

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: Added is_exited: bool to the VolunteerCampStatus Pydantic model.
  • Modified app/services/medical_camp_service.py: Updated get_volunteer_camp_status to determine is_exited status by checking for logout_time in 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 CampVisit record for the current camp that has a non-null logout_time.
  • Backward Compatibility: is_exited defaults to False in 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

  1. Setup: Ensure the backend is running and the database is migrated.
  2. Action: Create a CampVisit for a user and set a logout_time.
  3. Verification: Call the GET /api/v1/medical-camps/volunteer/signup-status endpoint.
  4. 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

Merge request reports

Loading