Add reset annotations button to admin table with database synchronization - #67
Conversation
Co-authored-by: IvoLeist <28399610+IvoLeist@users.noreply.github.com>
Co-authored-by: IvoLeist <28399610+IvoLeist@users.noreply.github.com>
Co-authored-by: IvoLeist <28399610+IvoLeist@users.noreply.github.com>
There was a problem hiding this comment.
@copilot
Not only the respective user annotation file needs to be reset but also the votes counts of the selected user need to be updated accordingly in the database
There was a problem hiding this comment.
Fixed in 6ac84d2. The reset_user_annotations() function now:
- Reads existing votes from the annotation file
- Decrements the corresponding vote counts in the database for each vote the user cast
- Then resets the annotation file
The function uses MAX(0, vote_count - 1) to prevent negative counts and includes error handling for database operations.
IvoLeist
left a comment
There was a problem hiding this comment.
Not only the respective user annotation file needs to be reset but also the votes counts of the selected user need to be updated accordingly in the database
Co-authored-by: IvoLeist <28399610+IvoLeist@users.noreply.github.com>
Fixed in 6ac84d2. The reset function now updates the database vote counts by decrementing them for each vote the user had cast before clearing the annotation file. Added tests to verify the database integration works correctly. |
Co-authored-by: IvoLeist <28399610+IvoLeist@users.noreply.github.com>
Admins need ability to reset user annotation files while preserving variant coordinates and randomization order, with automatic database vote count synchronization.
Changes
Core function (
R/admin_utils.R)reset_user_annotations()- reads TSV, identifies cast votes, decrements database vote counts, preserves coordinates/REF/ALT columns, clears voting data (agreement, observation, comment, session_id, time), writes backMAX(0, vote_count - 1)to prevent negative vote countsAdmin UI (
R/mod_admin.R)Testing (
tests/testthat/test-admin-reset-annotations.R)Database Integration
When resetting annotations:
Example
Before reset:
Database before:
vote_count_correct = 5,vote_count_germline = 3After reset:
Database after:
vote_count_correct = 4,vote_count_germline = 2(decremented by 1 each)User can re-vote on same randomized variant order with clean slate while maintaining accurate vote counts.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.