Skip to content

Commit

Permalink
[back] Improve session screen by batching user fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien committed Nov 18, 2022
1 parent 800c4e8 commit 3f3fdce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions opencti-platform/opencti-graphql/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4836,6 +4836,7 @@ export enum IdentitiesFilter {
Name = 'name',
Revoked = 'revoked',
UpdatedAt = 'updated_at',
XOpenctiAliases = 'x_opencti_aliases',
XOpenctiWorkflowId = 'x_opencti_workflow_id'
}

Expand Down Expand Up @@ -6896,6 +6897,7 @@ export enum LocationType {
}

export enum LocationsFilter {
Aliases = 'aliases',
Confidence = 'confidence',
Created = 'created',
CreatedBy = 'createdBy',
Expand Down
10 changes: 6 additions & 4 deletions opencti-platform/opencti-graphql/src/resolvers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { withFilter } from 'graphql-subscriptions';
import {
addBookmark,
addUser,
assignOrganizationToUser,
authenticateUser,
batchGroups,
batchOrganizations,
batchRoleCapabilities,
batchRoles,
batchUsers,
bookmarks,
deleteBookmark,
findAll,
Expand All @@ -29,14 +32,12 @@ import {
userAddRelation,
userCleanContext,
userDelete,
userDeleteOrganizationRelation,
userEditContext,
userEditField,
userIdDeleteRelation,
userRenewToken,
userWithOrigin,
batchOrganizations,
assignOrganizationToUser,
userDeleteOrganizationRelation,
} from '../domain/user';
import { BUS_TOPICS, logApp, logAudit } from '../config/conf';
import passport, { PROVIDERS } from '../config/providers';
Expand All @@ -55,6 +56,7 @@ const groupsLoader = batchLoader(batchGroups);
const organizationsLoader = batchLoader(batchOrganizations);
const rolesLoader = batchLoader(batchRoles);
const rolesCapabilitiesLoader = batchLoader(batchRoleCapabilities);
const usersLoader = batchLoader(batchUsers);

const userResolvers = {
Query: {
Expand All @@ -81,7 +83,7 @@ const userResolvers = {
userSubscriptions: (current, _, context) => getUserSubscriptions(context, context.user, current.id),
},
UserSession: {
user: (session, _, context) => findById(context, context.user, session.user_id),
user: (session, _, context) => usersLoader.load(session.user_id, context, context.user),
},
SessionDetail: {
ttl: (session) => fetchSessionTtl(session.id),
Expand Down

0 comments on commit 3f3fdce

Please sign in to comment.