diff --git a/README.md b/README.md index c7b0690c..ba3ca2b9 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@
-The Mentor building block enables effective mentoring interactions between mentors and mentees. The capability aims to create a transparent eco-system to learn, connect, solve, and share within communities. Mentor is an open-source mentoring application that facilitates peer learning and professional development by creating a community of mentors and mentees. +The User service block enables secure and highly extensible user management and organization management capabilities - User registration, Live and JWT basesd session management, Delete user, Forgot password with email notifications.
@@ -742,13 +742,11 @@ npm test # Used in -This project was built to be used with [Mentor Service](https://github.com/ELEVATE-Project/mentoring.git). +This project was built to be used with [Mentoring Service](https://github.com/ELEVATE-Project/mentoring.git), [Project Service](https://github.com/ELEVATE-Project/project-service.git), [Survey Service](https://github.com/ELEVATE-Project/samiksha-service.git), [User Service](https://github.com/ELEVATE-Project/user.git). -Notification service repo can be found [here](https://github.com/ELEVATE-Project/notification.git). +The frontend/mobile application for Mentoring [repo](https://github.com/ELEVATE-Project/mentoring-mobile-app) and Projects and Survey [repo](https://github.com/ELEVATE-Project/observation-survey-projects-pwa) -The PWA [repo](https://github.com/ELEVATE-Project/mentoring-mobile-app). - -You can learn more about the full implementation of Mentor [here](https://elevate-docs.shikshalokam.org/.mentorEd/intro) . +You can learn more about the full implementation of various capabilities of ELEVATE [here](https://elevate-docs.shikshalokam.org) .
# Team @@ -761,7 +759,7 @@ You can learn more about the full implementation of Mentor [here](https://elevat # Open Source Dependencies -Several open source dependencies that have aided user service development: +Several open-source dependencies have aided user service development: ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white) ![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge&logo=mongodb&logoColor=white) diff --git a/src/database/models/organization.js b/src/database/models/organization.js index fc2140f8..c80b5112 100644 --- a/src/database/models/organization.js +++ b/src/database/models/organization.js @@ -87,6 +87,12 @@ module.exports = (sequelize, DataTypes) => { sourceKey: 'code', as: 'organizationRegistrationCodes', }) + + Organization.hasMany(models.Organization, { + as: 'relatedOrgsDetails', + foreignKey: 'id', + constraints: false, + }) } return Organization diff --git a/src/database/queries/organization.js b/src/database/queries/organization.js index 0e6d4d9e..dd5b1cc1 100644 --- a/src/database/queries/organization.js +++ b/src/database/queries/organization.js @@ -52,24 +52,32 @@ exports.create = async (data) => { } exports.findOne = async (filter, options = {}) => { try { + let includes = [...(options.include || [])] if (options?.isAdmin) { - options = { - ...options, - include: [ - { - model: OrganizationRegistrationCode, - as: 'organizationRegistrationCodes', - attributes: ['registration_code'], - where: { status: 'ACTIVE', deleted_at: null, tenant_code: filter.tenant_code }, - required: false, - }, - ], - } + includes.push({ + model: OrganizationRegistrationCode, + as: 'organizationRegistrationCodes', + attributes: ['registration_code'], + where: { status: 'ACTIVE', deleted_at: null, tenant_code: filter.tenant_code }, + required: false, + }) + } + + if (options?.getRelatedOrgIdAndCode) { + includes.push({ + model: Organization, + as: 'relatedOrgsDetails', + attributes: ['id', 'code'], + required: false, + on: sequelize.literal(`"relatedOrgsDetails"."id" = ANY("Organization"."related_orgs")`), + }) } delete options.isAdmin + delete options?.getRelatedOrgIdAndCode let organization = await Organization.findOne({ where: filter, ...options, + include: includes, nest: true, }) if (!organization) return null diff --git a/src/package.json b/src/package.json index 4aa21d6e..24bb8e16 100644 --- a/src/package.json +++ b/src/package.json @@ -16,8 +16,8 @@ "elevate-migrations": "module/migrations/bin/migrations.js", "integration": "node app.js", "test:integration": "jest --verbose ./integration-test --config=integrationJest.config.js --runInBand", - "db:init": "sequelize-cli db:create && sequelize-cli db:migrate ", - "db:seed:all": "sequelize-cli db:seed:all" + "db:init": "sequelize-cli db:create || echo 'Database already exists or some issue while creating db, Please check' && sequelize-cli db:migrate ", + "db:seed:all": "sequelize-cli db:seed:all || echo 'Seeded data already exists or some issue while seeding the data, Please check' " }, "author": "Aman Kumar Gupta ", "license": "ISC", diff --git a/src/services/organization.js b/src/services/organization.js index 377dc0ec..baa0c944 100644 --- a/src/services/organization.js +++ b/src/services/organization.js @@ -410,7 +410,8 @@ module.exports = class OrganizationsHelper { if (tenantCode.trim()) filter.tenant_code = tenantCode } - const organisationDetails = await organizationQueries.findOne(filter) + const organisationDetails = await organizationQueries.findOne(filter, { getRelatedOrgIdAndCode: true }) + if (!organisationDetails) { return responses.failureResponse({ message: 'ORGANIZATION_NOT_FOUND', @@ -419,6 +420,15 @@ module.exports = class OrganizationsHelper { }) } + // if(organisationDetails.related_orgs && organisationDetails.related_orgs.length >0){ + // let orgFilters = {id:{[Op.in]:organisationDetails.related_orgs}} + // const relatedOrgsIdAndCode = await organizationQueries.findAll(orgFilters) + // organisationDetails.relatedOrgsIdAndCode = relatedOrgsIdAndCode.map(eachOrg => ({ + // id: eachOrg.id, + // code: eachOrg.code + // })); + // } + return responses.successResponse({ statusCode: httpStatusCode.ok, message: 'ORGANIZATION_FETCHED_SUCCESSFULLY',