-
-
Notifications
You must be signed in to change notification settings - Fork 6
Add History Logging for Family Merge and Detach Operations #790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vahid I tested this a bit more in depth and would say we need another iteration:
from the functional test:
- the lastModified date in the people table is somehow not updated could you maybe adapt the definition of the
simpleBulkSaveChangeHistoryto do this too?
from the code review
- since we do not show the history messages anywhere, I'm happy how they look like atm, but it would be great if you could move the
fromandtovalues out of thechangemessage into the right bits ofsimpleBulkSaveChangeHistory($table, $records, $changes, $from = [], $to = []) - maybe put "parent_id;" in front in the
changemessage to make clear that the parent_id in the record was changed.
I left comments in the code to make it clearer
| } | ||
| } | ||
| }); | ||
| simpleBulkSaveChangeHistory('people', $ids, 'merged to family (head: '.$oldest.')'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should maybe be simpleBulkSaveChangeHistory('people', $ids, 'parent_id; merged to family', [], ['int'=> <parent_id>);
| db_query('UPDATE people SET parent_id = NULL WHERE id = :id', ['id' => $id]); | ||
| } | ||
| }); | ||
| simpleBulkSaveChangeHistory('people', $ids, 'detached from family'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should maybe be simpleBulkSaveChangeHistory('people', $ids, 'parent_id; detached from family', ['int'=> <parent_id>, []);
This PR adds comprehensive history logging for family merge and detach operations in the beneficiary management system. Previously, when families were merged or detached (either via action buttons or drag & drop), no audit trail was created in the history table. This made it impossible to investigate cases where beneficiaries (including small children) were unexpectedly deactivated or moved between families.
Changes Made
1. In Manage Beneficiaries add history log if beneficiary is added to a family via drag & drop
include/people.php:503added to family via drag & drop2. In Manage Beneficiaries add history log if beneficiary is removed from a family via drag & drop
include/people.php:506removed from family via drag & drop3. In Manage Beneficiaries add history log if beneficiaries are merged to a family via selection and action button
include/people.php:442merged to family (head: [id])4. In Manage Beneficiaries add history log if beneficiaries are detached from a family via selection and action button
include/people.php:468detached from family5. Drag & Drop Implementation Details
library/lib/list.php:58-94listBulkMove()to track parent_id changes during drag & drop operations6. Cypress Tests
cypress/support/database.js,cypress/e2e/1_feature_tests/5_3_Manage_Beneficiaries.jscheckHistoryLog()command to verify history entries exist in databasegetBeneficiaryIdFromRow()command to extract beneficiary IDs from DOMlibrary/ajax/testhistorycheck.phpfor test verificationTesting
✅ All Cypress tests passing: