-
Notifications
You must be signed in to change notification settings - Fork 28
BUG 4334 #1599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
BUG 4334 #1599
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1525,17 +1525,34 @@ module.exports = class MenteesHelper { | |||||||||||||||||||||||||
| const query = utils.processQueryParametersWithExclusions(queryParams) | ||||||||||||||||||||||||||
| const userExtensionModelName = await menteeQueries.getModelName() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const defaults = await getDefaults() | ||||||||||||||||||||||||||
| if (!defaults.tenantCode) | ||||||||||||||||||||||||||
| return responses.failureResponse({ | ||||||||||||||||||||||||||
| message: 'DEFAULT_ORG_CODE_NOT_SET', | ||||||||||||||||||||||||||
| statusCode: httpStatusCode.bad_request, | ||||||||||||||||||||||||||
| responseCode: 'CLIENT_ERROR', | ||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||
|
Comment on lines
+1529
to
+1534
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix tenant validation error message key. Line 1531 returns Proposed patch if (!defaults.tenantCode)
return responses.failureResponse({
- message: 'DEFAULT_ORG_CODE_NOT_SET',
+ message: 'DEFAULT_TENANT_CODE_NOT_SET',
statusCode: httpStatusCode.bad_request,
responseCode: 'CLIENT_ERROR',
})As per coding guidelines 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let validationData = await entityTypeCache.getEntityTypesAndEntitiesWithCache( | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| status: common.ACTIVE_STATUS, | ||||||||||||||||||||||||||
| model_names: { [Op.overlap]: [userExtensionModelName] }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| tenantCode, | ||||||||||||||||||||||||||
| organizationCode, | ||||||||||||||||||||||||||
| userExtensionModelName | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let filteredQuery = utils.validateAndBuildFilters(query, validationData) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let connectedMenteeIds = [] | ||||||||||||||||||||||||||
| let connectedMenteesCount | ||||||||||||||||||||||||||
| if (queryParams.connected_mentees === 'true') { | ||||||||||||||||||||||||||
| const connectedQueryParams = { ...queryParams } | ||||||||||||||||||||||||||
| delete connectedQueryParams.connected_mentees | ||||||||||||||||||||||||||
| const connectedQuery = utils.processQueryParametersWithExclusions(connectedQueryParams) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const selectAll = queryParams.select_all === 'true' | ||||||||||||||||||||||||||
| const connectionDetails = await connectionQueries.getConnectionsDetails( | ||||||||||||||||||||||||||
| pageNo, | ||||||||||||||||||||||||||
| pageSize, | ||||||||||||||||||||||||||
| connectedQuery, | ||||||||||||||||||||||||||
| selectAll ? null : pageNo, | ||||||||||||||||||||||||||
| selectAll ? null : pageSize, | ||||||||||||||||||||||||||
| filteredQuery, | ||||||||||||||||||||||||||
| searchText, | ||||||||||||||||||||||||||
| queryParams.mentorId ? queryParams.mentorId : userId, | ||||||||||||||||||||||||||
| organization_codes, | ||||||||||||||||||||||||||
|
|
@@ -1547,9 +1564,6 @@ module.exports = class MenteesHelper { | |||||||||||||||||||||||||
| pageNo = null | ||||||||||||||||||||||||||
| pageSize = null | ||||||||||||||||||||||||||
| connectedMenteeIds = connectionDetails.data.map((item) => item.user_id) | ||||||||||||||||||||||||||
| // if (!connectedMenteeIds.includes(userId)) { | ||||||||||||||||||||||||||
| // connectedMenteeIds.push(userId) | ||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (typeof connectionDetails?.count === 'number') { | ||||||||||||||||||||||||||
| connectedMenteesCount = connectionDetails.count | ||||||||||||||||||||||||||
|
|
@@ -1567,27 +1581,6 @@ module.exports = class MenteesHelper { | |||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const defaults = await getDefaults() | ||||||||||||||||||||||||||
| if (!defaults.tenantCode) | ||||||||||||||||||||||||||
| return responses.failureResponse({ | ||||||||||||||||||||||||||
| message: 'DEFAULT_ORG_CODE_NOT_SET', | ||||||||||||||||||||||||||
| statusCode: httpStatusCode.bad_request, | ||||||||||||||||||||||||||
| responseCode: 'CLIENT_ERROR', | ||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let validationData = await entityTypeCache.getEntityTypesAndEntitiesWithCache( | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| status: common.ACTIVE_STATUS, | ||||||||||||||||||||||||||
| model_names: { [Op.overlap]: [userExtensionModelName] }, | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| tenantCode, | ||||||||||||||||||||||||||
| organizationCode, | ||||||||||||||||||||||||||
| userExtensionModelName | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let filteredQuery = utils.validateAndBuildFilters(query, validationData) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const emailIds = [] | ||||||||||||||||||||||||||
| const searchTextArray = searchText ? searchText.split(',') : [] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1389,34 +1389,38 @@ module.exports = class MentorsHelper { | |
| } | ||
|
|
||
| let connectedMentorsIds = [] | ||
| let connectedMentorsCount | ||
|
|
||
| if (queryParams.connected_mentors === 'true') { | ||
| const connectedQueryParams = { ...queryParams } | ||
| delete connectedQueryParams.connected_mentors | ||
| const connectedQuery = utils.processQueryParametersWithExclusions(connectedQueryParams) | ||
|
|
||
| const connectionDetails = await connectionQueries.getConnectionsDetails( | ||
| pageNo, | ||
| pageSize, | ||
| connectedQuery, | ||
| filteredQuery, | ||
| searchText, | ||
| queryParams.mentorId ? queryParams.mentorId : userId, | ||
| organization_codes, | ||
| [] // roles can be passed if needed | ||
| [], // roles can be passed if needed | ||
| tenantCode | ||
| ) | ||
|
|
||
| if (connectionDetails?.data?.length > 0) { | ||
| pageNo = null | ||
| pageSize = null | ||
| connectedMentorsIds = connectionDetails.data.map((item) => item.user_id) | ||
| if (!connectedMentorsIds.includes(userId)) { | ||
| connectedMentorsIds.push(userId) | ||
| } | ||
| } | ||
|
|
||
| // If there are no connected mentees, short-circuit and return empty | ||
| if (typeof connectionDetails?.count === 'number') { | ||
| connectedMentorsCount = connectionDetails.count | ||
| } | ||
|
Comment on lines
1410
to
+1417
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Connected mentor count can become inconsistent after self-inclusion. You add Proposed patch if (connectionDetails?.data?.length > 0) {
pageNo = null
pageSize = null
connectedMentorsIds = connectionDetails.data.map((item) => item.user_id)
+ if (typeof connectionDetails?.count === 'number') {
+ connectedMentorsCount = connectionDetails.count
+ }
if (!connectedMentorsIds.includes(userId)) {
connectedMentorsIds.push(userId)
+ if (typeof connectedMentorsCount === 'number') {
+ connectedMentorsCount += 1
+ }
}
}
-
- if (typeof connectionDetails?.count === 'number') {
- connectedMentorsCount = connectionDetails.count
- }As per coding guidelines Also applies to: 1577-1579 🤖 Prompt for AI Agents |
||
|
|
||
| // If there are no connected mentors, short-circuit and return empty | ||
| if (connectedMentorsIds.length === 0) { | ||
| return responses.successResponse({ | ||
| statusCode: httpStatusCode.ok, | ||
| message: 'MENTEE_LIST', | ||
| message: 'MENTOR_LIST', | ||
| result: { | ||
| data: [], | ||
| count: 0, | ||
|
|
@@ -1570,6 +1574,10 @@ module.exports = class MentorsHelper { | |
| } | ||
| } | ||
|
|
||
| if (connectedMentorsCount !== undefined) { | ||
| extensionDetails.count = connectedMentorsCount | ||
| } | ||
|
|
||
| return responses.successResponse({ | ||
| statusCode: httpStatusCode.ok, | ||
| message: 'MENTOR_LIST', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No-pagination path can still return mismatched
countvsdata.length.When pagination is omitted and
idsis empty, Line 576 caps results at 5000, but the count query still returns the full total. This can reintroduce list/count mismatch for large datasets.As per coding guidelines
src/database/queries/**: review queries for correctness/performance.🤖 Prompt for AI Agents