priyasirohi09 / joplin

Other
2 stars 91 forks source link

Feature Added : Delete Notes in Trash After 7 Days #241

Open Aarya01Patil opened 4 months ago

Aarya01Patil commented 4 months ago

This merge request implements the feature to automatically delete notes from the trash after 7 days. The implementation focuses on core functionality and testing, with the following key components:

Modified the Note model to include a trashedAt timestamp, which is set when a note is moved to the trash. Created a new scheduled task system in scheduledTasks.ts to handle the auto-deletion of old trashed notes. Updated relevant logic in Note.ts to support the new auto-delete functionality. Added comprehensive Jest tests to ensure the correct behavior of the new feature.

Key files modified/created:

packages/lib/models/Note.ts packages/lib/models/Note.test.ts packages/lib/services/scheduledTasks.ts (new file)

Testing: The new functionality has been thoroughly tested using Jest. New test cases have been added to Note.test.ts. These tests cover:

Setting the trashedAt timestamp when a note is moved to trash. Verifying that notes older than 7 days in trash are correctly identified for deletion. Ensuring that notes less than 7 days old in trash are not deleted. Checking that the scheduled task correctly deletes eligible notes.

Test results: All new and existing tests are passing. The new tests demonstrate that the auto-delete functionality works as expected, correctly identifying and removing notes that have been in the trash for more than 7 days while preserving more recent trash entries. Implementation details:

The Note.ts file now includes logic to handle the trashedAt timestamp and methods to identify notes eligible for deletion. The new scheduledTasks.ts file implements the scheduled task system, which will run the auto-delete function at regular intervals. Test cases in Note.test.ts have been expanded to cover various scenarios related to the new auto-delete feature.

Implementation: PR1

Next steps: Upon approval and merging of this request, we should:

Integrate the scheduled task with the main application loop. Update user documentation to reflect this new feature. Monitor system logs and gather user feedback to ensure the feature works as expected in production environments.

Please review the changes and let me know if any adjustments or additional information is needed.