Skip to content

Conversation

@iqbalpa
Copy link
Owner

@iqbalpa iqbalpa commented Jul 15, 2025

This PR refactors the application's data seeding process to improve startup performance and data organization.

Key Changes:

  • Asynchronous Seeding: The utils.SeedTasks(db) call in cmd/main.go is now executed in a goroutine with
    sync.WaitGroup, allowing the application to start without waiting for the seeding process to complete.
  • Dedicated Data Files:
    • Introduced internal/data/task.json with 100 dummy task entries.
    • Introduced internal/data/user.json with 10 dummy user entries.
    • Removed the generic internal/utils/data.json.
  • Generic Seeder: The internal/utils/seeder.go has been updated to:
    • Define UserDataPath and TaskDataPath constants for the new data file locations.
    • Modify readFile to accept a filename, enabling reading from specific JSON files.
    • Make getDummyData generic to handle both task and user data.
    • Update SeedTasks to read and save dummy tasks and users from their respective new JSON files.

Benefits:

  • Faster Application Startup: Asynchronous seeding prevents the main application from being blocked during data
    initialization.
  • Improved Data Organization: Separating task and user data into dedicated JSON files provides a clearer and more
    maintainable structure.

@iqbalpa iqbalpa merged commit 8830ba7 into master Jul 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants