Skip to content
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

[IMPROVEMENT] Improve the Send Reminder Notifications 2 Days Before Book Due Date Feature #58

Open
1 task done
ajaynegi45 opened this issue Oct 3, 2024 · 5 comments
Labels
enhancement New feature or request gssoc GirlScript Summer Of Code gssoc-ext hacktoberfest hacktoberfest-accepted level3 GirlScript Summer Of Code - 35 points status: ready for dev You can asked for this issue to be assigned (if not already assigned)

Comments

@ajaynegi45
Copy link
Owner

ajaynegi45 commented Oct 3, 2024

Is this feature already requested?

  • I have checked "open" and "closed" issues, and this is not a duplicate.

Problem or Missing Functionality

The system currently sends reminder notifications 2 days before the book's due date by querying the database on daily basis to check for due books. This process may involve daily database queries, which can lead to performance inefficiencies.

Improvement Request

  1. Optimize Database Queries:

    • Reduce the number of queries being made to the database while fetching due books for sending reminders.
  2. Performance Enhancement:

    • Analyze the existing workflow to identify potential bottlenecks.
    • Implement improvements that reduce the overall time taken to send reminders and the resource usage.
  3. Documentation:

    • Document the optimized solution clearly for future developers.
    • Include details about the new logic, optimized query flow, and how it impacts performance.

Expected Outcome

  • Fewer database queries.
  • Improved system performance, especially around the time reminders are sent.
  • Well-documented changes for easier maintenance.
@ajaynegi45 ajaynegi45 added status: awaiting triage Waiting for maintainers to verify (please do not start work on this yet) enhancement New feature or request hacktoberfest-accepted hacktoberfest status: ready for dev You can asked for this issue to be assigned (if not already assigned) gssoc GirlScript Summer Of Code gssoc-ext level3 GirlScript Summer Of Code - 35 points and removed status: awaiting triage Waiting for maintainers to verify (please do not start work on this yet) labels Oct 3, 2024
@7vk
Copy link

7vk commented Oct 4, 2024

Hey @ajaynegi45 I’d love to try my hands on this issue and see how I can contribute. Could you assign it to me? Looking forward to working on it!

@ajaynegi45
Copy link
Owner Author

Hey @ajaynegi45 I’d love to try my hands on this issue and see how I can contribute. Could you assign it to me? Looking forward to working on it!

Hey @7vk,

Thanks for showing interest in tackling this issue! I'd be happy to assign it to you, but before I do, could you walk me through how you plan to implement this feature in detail?

Also, before jumping in, I recommend giving the Readme.md a thorough read. It'll help you get a solid grasp of the project's goals and purpose. Plus, check out the Contributing.md file for some handy guidelines that’ll make your contribution process smoother, especially if you're new around here.

If you run into any questions or need help along the way, don’t hesitate to reach out!

@7vk
Copy link

7vk commented Oct 4, 2024

I suggest we create a separate entity to schedule reminders which would schedule the reminders when the book is borrowed.
So instead of scanning all borrowings daily, we query the specific reminders that are due.

What do you think about this approach? your guidance would be much appreciated.

@ajaynegi45
Copy link
Owner Author

ajaynegi45 commented Oct 5, 2024

I suggest we create a separate entity to schedule reminders which would schedule the reminders when the book is borrowed. So instead of scanning all borrowings daily, we query the specific reminders that are due.

What do you think about this approach? your guidance would be much appreciated.

Thank you for your suggestion, @7vk!
I really appreciate your input on creating a separate entity for scheduling reminders. It's a clever approach that could indeed optimize the system. Here are a few additional considerations and suggestions that might further enhance this solution:

Benefits of a Separate Reminder Entity

1. Reduced Database Load

By introducing a separate entity for scheduling reminders, we can avoid the need for daily scans of all borrowings, significantly cutting down the number of queries and reducing the strain on the database. Instead, we could query only the reminders that are due, leading to a more efficient process.

2. Improved Performance

This approach could make the system more scalable and performant, especially when handling a large volume of users and borrowings. Fewer and more targeted queries should result in noticeable improvements in speed and resource usage during the reminder process.


Edge Cases to Consider

To ensure the robustness of this approach, we’ll need to manage certain key edge cases effectively:

1. Book Renewals or Due Date Changes

If a user renews a book or if the due date changes for any reason, we need to ensure that the associated reminder is also updated. Failing to do so could result in sending incorrect reminders.

Solution:
Implement an event-driven system or listener that triggers updates to the reminder entity whenever a borrowed book’s due date is modified.

2. Book Returns Before the Due Date

If a user returns a book early, the corresponding reminder should be removed from the system to avoid sending unnecessary notifications.

Solution:
On book return, either soft-delete or remove the scheduled reminder entity. Optionally, you can archive reminders for reporting purposes, but they should no longer be active.


Additional Feature: Fine Calculation & Overdue Notifications

1. Daily Notifications After Due Date Passes

Once the due date for a book passes, the system should automatically send daily notifications to the user, reminding them that the due date has passed and that a fine of Rs. 10 per day is accruing. This notification should also display the current fine amount until the book is returned.

Solution:
After the due date passes, we’ll trigger a daily reminder until the book is returned. This can be optimized by calculating the fine dynamically based on the number of days overdue, rather than updating the fine amount in the database every day.

To avoid performance bottlenecks, we can batch-process overdue reminders in off-peak hours, sending notifications and calculating fines for all overdue books at once, ensuring that the process remains scalable even with a large user base.


Next Steps

I've assigned this issue to you and I'm confident that your approach will make the system more optimized, faster, and scalable. Be sure to document your code thoroughly using Javadoc comments to ensure clarity and maintainability. Feel free to reach out if you have any questions or need assistance as you proceed.

Looking forward to seeing your implementation!

@7vk
Copy link

7vk commented Oct 5, 2024

@ajaynegi45 I'll get it done. If I need help with anything I'll reach out.

@7vk 7vk removed their assignment Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gssoc GirlScript Summer Of Code gssoc-ext hacktoberfest hacktoberfest-accepted level3 GirlScript Summer Of Code - 35 points status: ready for dev You can asked for this issue to be assigned (if not already assigned)
Projects
None yet
Development

No branches or pull requests

2 participants