Skip to content

fix: Auto-Cancellation of Assignments on Unavailability#228

Merged
mehmetcangurbuz08 merged 2 commits into
developmentfrom
fix/auto-assign
Apr 7, 2026
Merged

fix: Auto-Cancellation of Assignments on Unavailability#228
mehmetcangurbuz08 merged 2 commits into
developmentfrom
fix/auto-assign

Conversation

@berat-sayin

Copy link
Copy Markdown
Contributor

Related to #227

I have updated the availability service to ensure that when a volunteer marks themselves as "unavailable",
any active assignments are automatically cancelled and the associated help requests are returned to the
PENDING state.

Key Changes:

  • backend/src/modules/availability/service.js:
    • Updated setAvailability to detect when isAvailable is set to false. If the volunteer has an active
      assignment, it is now cancelled via the repository, and the help request status is reset to
      PENDING.
    • Updated syncAvailability with similar logic: if the latest synced state is unavailable, any current
      assignment is cleared.
  • Improved Integration Tests:
    • Added POST /api/availability/toggle to false cancels active assignment to verify that toggling
      availability to false deletes the assignment and resets the request.
    • Added POST /api/availability/sync to false cancels active assignment to verify the same behavior
      for bulk sync operations.
  • Enhanced Unit Tests:
    • Added test cases to tests/unit/modules/availability/service.test.js for both setAvailability and
      syncAvailability to ensure they correctly interact with the repository when a volunteer becomes
      unavailable.

This ensures that requesters are not left waiting for a volunteer who is no longer active, and their
requests can be immediately picked up by other available volunteers.

@berat-sayin berat-sayin added this to the MVP Milestone milestone Apr 6, 2026
@berat-sayin berat-sayin added bug Something isn't working backend labels Apr 6, 2026

@mehmetcangurbuz08 mehmetcangurbuz08 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid merging.

@mehmetcangurbuz08
mehmetcangurbuz08 merged commit 3f52e23 into development Apr 7, 2026
2 checks passed
@mehmetcangurbuz08
mehmetcangurbuz08 deleted the fix/auto-assign branch April 7, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants