Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ module.exports = class AdminService {
try {
const orgData = await orgQueries.findOne({ organization_code: orgCode }, tenantCode)
if (orgData) {
await cacheHelper.organizations.set(tenantCode, orgCode, orgCode, orgData)
await cacheHelper.organizations.set(tenantCode, orgCode, orgData.organization_id, orgData)
warmupResults.organizations = 1
}
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion src/services/mentees.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module.exports = class MenteesHelper {
}

delete mentee.user_id
const visibleToOrganizations = mentee.visible_to_organizations
delete mentee.visible_to_organizations

const defaults = await getDefaults()
Expand Down Expand Up @@ -230,7 +231,7 @@ module.exports = class MenteesHelper {
user_id: id, // Add user_id to match mentor read response
...sanitizedMenteeData,
...processDbResponse,
visible_to_organizations: mentee.visible_to_organizations, // Add to match mentor read
visible_to_organizations: visibleToOrganizations, // Add to match mentor read
settings: mentee.settings, // Add settings to match mentor read
displayProperties,
}
Expand Down
19 changes: 17 additions & 2 deletions src/services/org-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ module.exports = class OrgAdminService {
{ organization_id: decodedToken.organization_id }, //custom filter for where clause
tenantCode
)
// Clear per-user profile caches so stale policy fields are not served after bulk update
try {
await cacheHelper.mentee.deleteAll(tenantCode)
await cacheHelper.mentor.deleteAll(tenantCode)
} catch (cacheError) {
console.error('Failed to invalidate mentee/mentor caches after setOrgPolicies:', cacheError)
}
// commenting as part of first level SAAS changes. will need this in the code next level
// await sessionQueries.updateSession(
// {
Expand Down Expand Up @@ -672,12 +679,20 @@ module.exports = class OrgAdminService {
await menteeQueries.removeVisibleToOrg(orgId, deltaOrganizationIds, tenantCode)
}

// Clear per-user profile caches — visible_to_organizations field is cached in mentee/mentor profiles
try {
await cacheHelper.mentee.deleteAll(tenantCode)
await cacheHelper.mentor.deleteAll(tenantCode)
} catch (cacheError) {
console.error('Failed to invalidate mentee/mentor caches after updateRelatedOrgs:', cacheError)
}

// Invalidate organization cache for the affected organization
try {
// Get organization details to extract orgCode for cache invalidation
const organizationDetails = await userRequests.fetchOrgDetails({ organizationId: orgId, tenantCode })
if (organizationDetails.success && organizationDetails.data && organizationDetails.data.result) {
const orgCode = organizationDetails.data.result.organization_code || orgId
const orgCode = organizationDetails?.data?.result?.code
if (orgCode) {
await cacheHelper.organizations.delete(tenantCode, orgCode, orgId)
}
} catch (cacheError) {
Expand Down