Skip to content
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

removed user read call in sessions and added organization key to model #960

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from

Conversation

rakeshSgr
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@aks30 aks30 left a comment

Choose a reason for hiding this comment

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

Reviewed on 11 Oct

src/database/models/userExtension.js Outdated Show resolved Hide resolved
require('dotenv').config()
const materializedViewsService = require('@generics/materializedViews')

/** @type {import('sequelize-cli').Migration} */
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr Remove copy in name, see if some better name can be given, please add comment in file what this migration does.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@aks30 its invalid file, not required

@@ -127,6 +165,8 @@ module.exports = class UserHelper {
competency: userDetails.competency,
designation: userDetails.designation,
language: userDetails.language,
organization_name: userDetails.organization.name,
image: userDetails.image,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr we can add this in column i am thinking, anyways in ELEVATE we have user image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

Copy link
Collaborator

@aks30 aks30 left a comment

Choose a reason for hiding this comment

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

Reviewed on 14 Oct

@@ -0,0 +1,3335 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr Let's move these files in project root, in sunbird-mentoring and mentoring

try {
const { STRING } = Sequelize

await queryInterface.addColumn('organization_extension', 'organization_name', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr let's call it name only

@@ -39,6 +39,7 @@ module.exports = (sequelize, DataTypes) => {
},
mentee_visibility_policy: { type: DataTypes.STRING },
external_mentee_visibility_policy: { type: DataTypes.STRING },
organization_name: { type: DataTypes.STRING },
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr rename it to just name please, Also update the corresponding DB diagrams for documentation as well.

try {
const { STRING } = Sequelize

await queryInterface.addColumn('organization_extension', 'organization_name', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr name can be an index if its fetched very often

Copy link
Collaborator

@aks30 aks30 left a comment

Choose a reason for hiding this comment

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

Reviewed on 16 Oct

interface-routes/sunbird-mentoring.json Show resolved Hide resolved
interface-routes/sunbird-mentoring.json Outdated Show resolved Hide resolved
src/services/sessions.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@aks30 aks30 left a comment

Choose a reason for hiding this comment

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

Reviewed partially on 13 Nov

@@ -24,6 +24,16 @@ const decrypt = async (encryptedEmail) => {
throw err
}
}
const emailEncryption = { encrypt, decrypt }

async function decryptAndValidate(data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr What validation happens here? Can we start adding function signature, name, description, argument examples and response signature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we are trying to decrypt the email if success it returns decrypted value else it returns false

}
}

static async getUsersByEmailIds(emailIds) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr Can we start adding function signatures, along with sample arguments and responses?

static async getUsersByEmailIds(emailIds) {
try {
const userFilterClause =
emailIds.length === 0 ? '' : `email IN (${emailIds.map((id) => `'${id}'`).join(',')})`
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr is the email column indexed? Is it encrypted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

email is not indexed. yes its encrypted.

should we add index for email ?

try {
let orgReadUrl
if (organizationId && db == true) {
const organizationDetails = await organisationExtensionQueries.findOne({ organization_id: organizationId })
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr don't we need org code based query as below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

currently we are not storing org code in OrganizationExtension


if (userId) profileUrl += `/${userId}`
if (userDetails.image) {
userDetails.image = await getDownloadableUrl(userDetails.image).result
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr don't we have to check whether we have http path of just storage bucket path before making a call to user service even when db is true?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added check in the getDownloadableUrl function

@@ -103,38 +142,90 @@ const fetchUserDetails = async ({ token, userId }) => {
* @returns
*/

const getListOfUserDetails = function (userIds, excludeDeletedRecords = false) {
const getListOfUserDetails = function (userIds, db = false, excludeDeletedRecords = false) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr Why default value is false here and true at other places? Also let's define function signatures in all functions we modify going forward?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this function has used in migrations so I kept db = false as default.

// Enrich user details with roles and organization info
userDetails.forEach(async (user) => {
if (user.image) {
user.image = await getDownloadableUrl(user.image).result
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rakeshSgr Why do we have to make a API call in loop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

currently we can get only one path at time from user service API

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