Closed KrupaPanchal2527 closed 1 month ago
@aadeshkulkarni I just started working on this but I think this might not work out. Because if we are planning to fetch issues when clicking on accordion then we won't be able to display the issue count on the top-right of the card on page load. Either we remove the issue count (which I don't think will be a good idea) or we need to come up with another way of optimizing how we are fetching the data. What are your thoughts?
Given the context of having an average of 1,000 repositories, each with an average of 10 issues, the solution needs to balance initial load times, user experience, and complexity of implementation.
Here is an approach:
Initial Repository Fetch:
User Requests Repository Details:
Lazy Loading of Issues:
Background Prefetching: (Out of scope for now, since we don't have a background worker + We are not monitoring user activity)
By separating concerns (repository details and issues) and leveraging asynchronous background tasks, this approach provides a balanced solution to meet the requirements effectively.
This commit solves this problem in the following way:
There are 2 flows:
Cron flow: Cron jobs can be scheduled to execute /api/cron once every 12 hours. They can be easily configured on Vercel here.
App flow: This is how the app will behave when a user opens the application.
This PR slightly fixes this problem.
Current behavior for fetching repository details and list of issues -
repos.json
Issue with above approach Whenever the cache has expired, it takes too long to fetch all the repo details and it's corresponding issue list.
Ideas on how to optimize We don't need issues list right away, so we can avoid fetching issues details while fetching the repository details for the first time. Whenever user opens up the accordion to see issues we can fetch them right away. To further optimize it, once issue list is fetched we can store it inside a cache with expiry time.