Skip to content

refactor: update default service and model in createAgentController (…#897

Open
Anushtha-Rathore wants to merge 2 commits into
Walkover-Web-Solution:testingfrom
Anushtha-Rathore:final-schema-for-configuration-versions
Open

refactor: update default service and model in createAgentController (…#897
Anushtha-Rathore wants to merge 2 commits into
Walkover-Web-Solution:testingfrom
Anushtha-Rathore:final-schema-for-configuration-versions

Conversation

@Anushtha-Rathore

Copy link
Copy Markdown
Contributor

final schema for configuration and version and its migration

…alkover-Web-Solution#888)

* refactor: update default service and model in createAgentController

* Update src/controllers/agentConfig.controller.js

Co-authored-by: windsurf-bot[bot] <189301087+windsurf-bot[bot]@users.noreply.github.com>

---------

Co-authored-by: Husain Baghwala <husainhackerrank@gmail.com>
Co-authored-by: windsurf-bot[bot] <189301087+windsurf-bot[bot]@users.noreply.github.com>
@Natwar589

Copy link
Copy Markdown
Collaborator

Your card was not found on the dbdash with the branch final-schema-for-configuration-versions

@windsurf-bot windsurf-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other comments (4)
  • migrations/mongo/configurationAndVersions.js (140-202) The MongoDB operations in Step 4 (renaming fields) lack error handling. Consider wrapping these operations in try/catch blocks to ensure the script can continue or at least clean up properly if one operation fails.
  • src/mongoModel/schemas/shared.js (56-59) There's an inconsistency in naming between schemas: fallBackSchema uses `is_enable` while guardrailsSchema uses `is_enabled`. Consider standardizing to either `is_enable` or `is_enabled` across all schemas for consistency.
  • src/mongoModel/schemas/shared.js (2-2) There's a commented import for ModelConfigService. Is this import still needed? If not, consider removing the comment to keep the code clean. If it will be needed in the future, consider adding a TODO comment explaining why it's commented out.
  • src/mongoModel/schemas/shared.js (106-106) The field `IsstarterQuestionEnable` doesn't follow the camelCase naming convention used for other fields in this file. Consider renaming to `isStarterQuestionEnabled` for consistency with JavaScript naming conventions.

💡 To request another review, post a new comment with "/windsurf-review".

Comment on lines +168 to +171
const copyImageSizeToSizeConfig = await configurations.updateMany(
{ "configuration.image_size": { $exists: true }, "configuration.size": { $exists: false } },
[{ $set: { "configuration.size": "$configuration.image_size" } }]
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The updateMany operations for copying image_size to size are using an incorrect syntax. When using an aggregation pipeline with $set, you should not wrap it in an array.

Suggested change
const copyImageSizeToSizeConfig = await configurations.updateMany(
{ "configuration.image_size": { $exists: true }, "configuration.size": { $exists: false } },
[{ $set: { "configuration.size": "$configuration.image_size" } }]
);
const copyImageSizeToSizeConfig = await configurations.updateMany(
{ "configuration.image_size": { $exists: true }, "configuration.size": { $exists: false } },
[{ $set: { "configuration.size": "$configuration.image_size" } }]

Same issue exists in the versions collection update on line 183.

Comment on lines +73 to +79
const actionTypeSchema = new Schema(
{
description: { type: String },
type: { type: String },
variable: { type: String }
},
{ _id: false }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The actionTypeSchema doesn't specify default values for its fields, unlike other schemas in this file. Consider adding appropriate default values to maintain consistency and prevent potential issues with undefined values.

Comment on lines +197 to +201
const setDefaultSizeVersion = await versions.updateMany(
{ "configuration.image_size": { $exists: false }, "configuration.size": { $exists: false } },
{ $set: { "configuration.size": "" } }
);
console.log(` ✓ Set default size (where both missing): ${setDefaultSizeVersion.modifiedCount} versions`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The script sets a default empty string for size when both image_size and size are missing in versions (lines 197-201), but doesn't do the same for configurations. This could lead to inconsistency between collections. Consider adding a similar operation for configurations.

@Natwar589

Copy link
Copy Markdown
Collaborator

Your card was not found on the dbdash with the branch final-schema-for-configuration-versions

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.

3 participants