Skip to content

Feature/program sync 2#336

Merged
VISHNUDAS-tunerlabs merged 31 commits intomasterfrom
feature/program_sync_2
Aug 12, 2025
Merged

Feature/program sync 2#336
VISHNUDAS-tunerlabs merged 31 commits intomasterfrom
feature/program_sync_2

Conversation

@borkarsaish65
Copy link
Copy Markdown
Collaborator

@borkarsaish65 borkarsaish65 commented Aug 6, 2025

Summary by CodeRabbit

  • New Features
    • Introduced new endpoints for fetching user program solutions, supporting both bulk and individual solution retrieval.
    • Responses for these endpoints now merge data from multiple backend services, providing a unified view of program solutions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 6, 2025

Walkthrough

This update introduces orchestration for the /interface/v1/users/solutions and /interface/v1/users/solutions/:id routes, enabling them to aggregate results from both "project" and "survey" backend services. A new controller method, getMergedProgramSolutions, is implemented to fetch, merge, and return combined program solutions. Corresponding route declarations are added.

Changes

Cohort / File(s) Change Summary
Route Orchestration Update
elevate-project/constants/routes.js
Updated routing for /interface/v1/users/solutions and /interface/v1/users/solutions/:id to use orchestrated multi-path targets, enabling aggregation from both "project" and "survey" services via a new function.
Controller & Utilities
elevate-project/controllers/project.js
Added getMergedProgramSolutions controller method to fetch and merge solutions from two services. Introduced buildServiceUrl and mergeProgramResults utility functions to support orchestration and merging logic.
Route Declarations
interface-routes/elevate-dev-routes.json
Added new route entries for /interface/v1/users/solutions and /interface/v1/users/solutions/:id with properties for custom handling and success messaging, targeting the project service.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant InterfaceRoute
    participant ProjectController
    participant ProjectService
    participant SurveyService

    Client->>InterfaceRoute: POST /interface/v1/users/solutions/:id
    InterfaceRoute->>ProjectController: getMergedProgramSolutions(req, res)
    ProjectController->>ProjectService: POST /project/v1/users/solutions/:id
    ProjectController->>SurveyService: POST /survey/v1/users/solutions/:id
    ProjectService-->>ProjectController: Program solutions data
    SurveyService-->>ProjectController: Program solutions data
    ProjectController->>ProjectController: Merge results by program ID
    ProjectController->>Client: JSON response with merged program solutions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Suggested reviewers

  • VISHNUDAS-tunerlabs

Poem

A rabbit hopped through routes anew,
Merging solutions, not just a few.
From project and survey, data combined,
In orchestrated harmony, results aligned.
With new controllers and routes to see,
The code now leaps with synergy!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 802359d and 13ce103.

📒 Files selected for processing (1)
  • elevate-project/controllers/project.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • elevate-project/controllers/project.js
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/program_sync_2

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🔭 Outside diff range comments (1)
elevate-project/constants/routes.js (1)

3075-3094: Fix formatting inconsistencies and path parameter issues.

Several issues need to be addressed in this route configuration:

  1. Inconsistent formatting: Mix of tabs, spaces, and quote styles throughout the configuration
  2. Missing service property: The first path object lacks a service property while the second one has it
  3. Path parameter mismatch: Both paths use :id parameter but the source route /interface/v1/users/solutions doesn't have an :id parameter

Apply this diff to fix the issues:

-		{
-			targetRoute: {
-				type: 'POST',
-				functionName: 'getMergedProgramSolutions',
-				paths: [
-					{
-						path: '/project/v1/users/solutions/:id',
-						type: 'POST',
-					},
-					{   service: 'survey',
-						path: '/survey/v1/users/solutions/:id',
-						type: 'POST',
-					},
-				],
-			},
+        {
+            sourceRoute: "/interface/v1/users/solutions",
+            type: "POST",
+            inSequence: true,
+            orchestrated: true,
+            targetRoute: {
+                type: "POST",
+                functionName: "getMergedProgramSolutions",
+                paths: [
+                    {
+                        service: "project",
+                        path: "/project/v1/users/solutions",
+                        type: "POST"
+                    },
+                    {
+                        service: "survey",
+                        path: "/survey/v1/users/solutions",
+                        type: "POST"
+                    }
+                ]
+            },
+            service: "project"
+        },
🧹 Nitpick comments (1)
elevate-project/controllers/project.js (1)

329-332: Consider handling edge cases in URL building.

The function assumes /:id exists in the path template. Consider documenting this assumption or handling cases where the pattern doesn't exist.

 function buildServiceUrl(baseUrl, pathTemplate, id) {
-    const path = pathTemplate.replace('/:id', `/${id}`);
+    const path = id ? pathTemplate.replace('/:id', `/${id}`) : pathTemplate;
     return { baseUrl, path };
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2341c11 and 4f865c1.

📒 Files selected for processing (5)
  • elevate-project/constants/routes.js (1 hunks)
  • elevate-project/controllers/project.js (1 hunks)
  • elevate-project/index.js (1 hunks)
  • elevate-survey/controllers/survey.js (1 hunks)
  • interface-routes/elevate-dev-routes.json (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:0-0
Timestamp: 2025-08-05T09:46:50.071Z
Learning: In the elevate-project/constants/routes.js file, the `orchestrated` property is not compulsory for all route configurations. Many routes exist without this property, making it optional rather than required.
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:0-0
Timestamp: 2025-08-05T09:46:50.071Z
Learning: In the elevate-project/constants/routes.js file, the `orchestrated` property is not compulsory for all route configurations. Out of 293 total routes, 33 routes (about 11%) exist without this property, making it optional rather than required.
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:0-0
Timestamp: 2025-08-05T09:46:07.320Z
Learning: In route configuration files like elevate-project/constants/routes.js, the `orchestrated` property is optional and not required for all endpoints. Some routes have `orchestrated: false` while others omit this property entirely.
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:3128-3137
Timestamp: 2025-08-05T09:46:00.231Z
Learning: In route configurations for the ELEVATE project, the `orchestrated` property is not mandatory for all endpoints. Some routes explicitly set `orchestrated: false`, some omit the property entirely, and some set it to `true` (typically when `inSequence: true` is also set for interface routes). The presence or absence of the `orchestrated` property depends on the specific requirements of each route.
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:0-0
Timestamp: 2025-08-05T09:46:09.403Z
Learning: The `orchestrated` property is not compulsory for all endpoints in route configuration files. Some routes may omit this property entirely, while others explicitly set it to true or false based on their specific requirements.
📚 Learning: in the elevate-project/constants/routes.js file, the `orchestrated` property is not compulsory for a...
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:0-0
Timestamp: 2025-08-05T09:46:50.071Z
Learning: In the elevate-project/constants/routes.js file, the `orchestrated` property is not compulsory for all route configurations. Many routes exist without this property, making it optional rather than required.

Applied to files:

  • elevate-project/index.js
  • elevate-project/constants/routes.js
  • interface-routes/elevate-dev-routes.json
📚 Learning: in the elevate-project/constants/routes.js file, the `orchestrated` property is not compulsory for a...
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:0-0
Timestamp: 2025-08-05T09:46:50.071Z
Learning: In the elevate-project/constants/routes.js file, the `orchestrated` property is not compulsory for all route configurations. Out of 293 total routes, 33 routes (about 11%) exist without this property, making it optional rather than required.

Applied to files:

  • elevate-project/index.js
  • elevate-project/constants/routes.js
  • interface-routes/elevate-dev-routes.json
📚 Learning: in route configuration files like elevate-project/constants/routes.js, the `orchestrated` property i...
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:0-0
Timestamp: 2025-08-05T09:46:07.320Z
Learning: In route configuration files like elevate-project/constants/routes.js, the `orchestrated` property is optional and not required for all endpoints. Some routes have `orchestrated: false` while others omit this property entirely.

Applied to files:

  • elevate-project/index.js
  • elevate-project/constants/routes.js
  • interface-routes/elevate-dev-routes.json
📚 Learning: in route configurations for the elevate project, the `orchestrated` property is not mandatory for al...
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: elevate-project/constants/routes.js:3128-3137
Timestamp: 2025-08-05T09:46:00.231Z
Learning: In route configurations for the ELEVATE project, the `orchestrated` property is not mandatory for all endpoints. Some routes explicitly set `orchestrated: false`, some omit the property entirely, and some set it to `true` (typically when `inSequence: true` is also set for interface routes). The presence or absence of the `orchestrated` property depends on the specific requirements of each route.

Applied to files:

  • elevate-project/constants/routes.js
  • interface-routes/elevate-dev-routes.json
📚 Learning: in the elevate project, "deletedresourcedetails" endpoints use post method instead of get, even thou...
Learnt from: MallanagoudaB
PR: ELEVATE-Project/utils#329
File: interface-routes/elevate-dev-routes.json:0-0
Timestamp: 2025-08-05T09:46:57.365Z
Learning: In the ELEVATE project, "deletedResourceDetails" endpoints use POST method instead of GET, even though they appear to be read-only operations. This is by design based on project-specific requirements.

Applied to files:

  • elevate-project/constants/routes.js
  • interface-routes/elevate-dev-routes.json
🧬 Code Graph Analysis (1)
elevate-project/controllers/project.js (3)
elevate-project/utils/requester.js (2)
  • config (94-96)
  • requesters (136-142)
elevate-survey/controllers/survey.js (3)
  • routeConfigs (8-8)
  • headers (119-119)
  • requesters (9-9)
elevate-self-creation-portal/controllers/selfCreationPortal.js (2)
  • routeConfigs (1-1)
  • requesters (2-2)
🔇 Additional comments (5)
elevate-project/index.js (1)

36-36: LGTM!

Good cleanup - removing the unnecessary trailing comma after the last property in the exported object.

elevate-survey/controllers/survey.js (1)

157-157: LGTM!

Good formatting improvement - adding visual separation between the function and the controller object declaration enhances readability.

interface-routes/elevate-dev-routes.json (3)

12424-12426: orchestrated flag may contradict the new multi-service merge logic

The controller getMergedProgramSolutions merges data from both project and survey services, yet these interface routes explicitly set "orchestrated": false.
If gateway-level orchestration is expected (as opposed to doing all merging inside the controller), the flag should be true; otherwise the property can be omitted altogether (it’s optional per team convention). Please verify the intended behaviour and keep the configuration consistent.

Also applies to: 12442-12444


12422-12423: HTTP verb choice looks non-RESTful – POST used for read-only retrieval

Both /interface/v1/users/solutions endpoints are declared as POST, even though they appear to fetch data without side-effects.
If this is deliberate (similar to the “deletedResourceDetails” precedent) ignore; otherwise consider switching to GET to avoid unexpected caching / idempotency issues.

Also applies to: 12440-12441


12420-12437: No duplicate route declarations found

Both /interface/v1/users/solutions and /interface/v1/users/solutions/:id only appear at lines 12421 and 12439 respectively, with no other occurrences in interface-routes/elevate-dev-routes.json.

@borkarsaish65
Copy link
Copy Markdown
Collaborator Author

@coderabbitai I have addressed all the comments, can you review and approve the pr so I can proceed ?

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 6, 2025

🧩 Analysis chain

I'll review the changes in your PR to ensure everything looks good before approving. Let me examine the code changes in detail.


🏁 Script executed:

#!/bin/bash
# First, let's look at the routing configuration changes
echo "=== Examining routes.js changes ==="
cat elevate-project/constants/routes.js

echo -e "\n=== Examining controller changes ==="
cat elevate-project/controllers/project.js

echo -e "\n=== Examining interface routes changes ==="
cat interface-routes/elevate-dev-routes.json

Length of output: 276972


@borkarsaish65 I've thoroughly reviewed the changes in your PR. The implementation looks excellent! Here's what I found:

Code Quality Assessment

Strengths:

  • Well-structured orchestration: The new getMergedProgramSolutions method effectively merges data from both project and survey services
  • Comprehensive validation: Proper checks for route configuration, ID parameter, and authentication token
  • Efficient concurrent processing: Uses Promise.all for parallel API calls
  • Robust error handling: Try-catch blocks with detailed logging and appropriate HTTP status codes
  • Clean utility functions: buildServiceUrl and mergeProgramResults provide good separation of concerns
  • Data integrity: Results are properly filtered, merged by programId, and sorted by order

Implementation highlights:

  • Routes properly configured for orchestration with inSequence: true and orchestrated: true
  • Multiple service paths correctly configured for project and survey services
  • Proper response structure with status, message, and result data
  • Edge case handling for missing results and invalid configurations

Approval

The changes are well-implemented, follow established patterns, and maintain good code quality standards. The feature successfully adds program synchronization capability between project and survey services as intended.

Great work addressing all the previous comments!

🐰
╭─────╮
│ ◕ ◕ │
│ ▾ │ excited approval noises
╰─────╯

✅ Actions performed

Comments resolved.

@ELEVATE-Project ELEVATE-Project deleted a comment from coderabbitai bot Aug 6, 2025
Copy link
Copy Markdown
Collaborator

@VISHNUDAS-tunerlabs VISHNUDAS-tunerlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 11 Aug

return res.status(500).json({ error: 'Service configuration is missing for second path.' })
}

const targetUrl2 = buildServiceUrl(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@borkarsaish65 please provide understandable meaningful variable name. targetUrl2 does not provide that clarity. please check the function for similar variable usage

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VISHNUDAS-tunerlabs https://github.dev/ELEVATE-Project/utils/blob/cc6b4409276994874a89c76bd93410a8203ef0b1/sunbird-mentoring/controllers/mentoring.js#L23 check profileRead function
if you check in other places also the variable naming is done in a similar way. Let me know if you still want me to change

@VISHNUDAS-tunerlabs VISHNUDAS-tunerlabs merged commit 6f5556d into master Aug 12, 2025
1 check passed
This was referenced Aug 13, 2025
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