Skip to content

feat: Introduce new service modules for project, quotation, daily upd… - #54

Merged
JahnaviVeera merged 1 commit into
spotmies:masterfrom
JahnaviVeera:Jahnavi_Dev
Mar 17, 2026
Merged

JahnaviVeera merged 1 commit into
spotmies:masterfrom
JahnaviVeera:Jahnavi_Dev

Conversation

@JahnaviVeera

Copy link
Copy Markdown
Collaborator

…ates, notifications, and payments, including comprehensive project creation and retrieval logic.

…ates, notifications, and payments, including comprehensive project creation and retrieval logic.
@JahnaviVeera
JahnaviVeera merged commit 32a2f64 into spotmies:master Mar 17, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

🤖 AI Code Review

📌 Summary

  • The changes introduce notifications for the "accountant" role across multiple modules, ensuring they are informed about relevant events.
  • The code generally follows good practices, but there are areas for improvement in error handling, maintainability, and performance.

💬 Inline Comments (File-wise)

check_users.ts

  • Line 1: The import statement for prisma has been updated to use a custom configuration file. Ensure that ./src/config/prisma.client is correctly configured and handles connection pooling efficiently.

    • ✅ Suggestion: Verify that the custom Prisma client configuration includes proper connection management (e.g., pooling, retries).
  • Line 6: The main function now uses select to limit the fields retrieved from the database. This is a good practice for performance optimization.

    • ✅ Suggestion: Consider adding error handling for the findMany call to gracefully handle database issues.

src/modules/daily-updates/daily-updates.services.ts

  • Line 148: The SocketService.getInstance().emitToRole method is used to notify accountants. Ensure that the "accountant" role exists and is properly managed in the system.

    • ✅ Suggestion: Add a fallback mechanism if the role "accountant" is not found or if the socket connection fails.
  • Line 296: Notifications for accountants are added for admin daily updates. This is consistent with the changes made elsewhere.

    • ✅ Suggestion: Consider consolidating repeated notification logic into a reusable function to improve maintainability.

src/modules/notifications/notifications.services.ts

  • Line 88: The notifyAdmins function now includes accountants in the notification logic. While this is functional, the repeated use of OR conditions in the query can become harder to maintain as more roles are added.
    • ✅ Suggestion: Refactor the query to use a configurable list of roles (e.g., const rolesToNotify = ["admin", "accountant"];) for better scalability.

src/modules/payments/payments.services.ts

  • Line 145: Notifications for payments now include accountants. The try-catch block is a good addition for error handling, but the error message could be more descriptive.

    • ✅ Suggestion: Include the payment ID or other context in the error log to aid debugging.
  • Line 292: Similar logic for payment updates is added. The repeated notification logic could be abstracted into a helper function.

    • ✅ Suggestion: Create a utility function like emitNotificationToRoles(message, roles, eventType) to reduce duplication.

src/modules/project/project.services.ts

  • Line 158: Notifications for project creation now include accountants. The try-catch block is appropriate, but the error handling could be improved.
    • ✅ Suggestion: Log the error with more context, such as the project ID or name, to make debugging easier.

src/modules/quotations/quotations.services.ts

  • Line 488: Notifications for quotation approval now include accountants. Ensure that the SocketService handles large-scale notifications efficiently.

    • ✅ Suggestion: Consider batching socket emissions if the number of recipients grows significantly.
  • Line 567: Notifications for quotation rejection now include accountants. The repeated logic for emitting notifications could be centralized.

    • ✅ Suggestion: Refactor the notification logic into a shared utility function to improve maintainability.

⚠️ High-Risk Issues

  • Error Handling: In several places (e.g., createPayment, createProject, approveQuotation), the error handling is minimal and does not provide sufficient context for debugging. This could lead to difficulties in diagnosing issues in production.

    • ✅ Suggestion: Enhance error logs with contextual information (e.g., IDs, names, or other relevant data).
  • Socket Emissions: The repeated use of SocketService.getInstance().emitToRole could lead to performance bottlenecks if the number of recipients grows significantly. Ensure that the socket service is optimized for scalability.

    • ✅ Suggestion: Test the socket service under high load and consider batching or rate-limiting emissions if necessary.
  • Role Management: The addition of the "accountant" role assumes that this role is consistently defined and managed across the system. If the role is missing or misconfigured, notifications may fail silently.

    • ✅ Suggestion: Validate the existence of roles before emitting notifications and log warnings if roles are missing.

⚠️ High-Risk Issues

No critical security vulnerabilities or data loss risks were identified in the changes. However, the following areas require attention:

  • Error handling improvements.
  • Performance optimization for socket emissions.

By addressing the suggestions above, the code can be made more robust, maintainable, and scalable. Let me know if you need further clarification or assistance!


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants