Skip to content

Commit

Permalink
Working
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfarrell76 committed Oct 18, 2023
1 parent aca82ac commit 5839716
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/graphql/fetchAllUsers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLClient } from 'graphql-request';
import { TEAMS } from './gqls';
import { USERS } from './gqls';
import { makeGraphQLRequest } from './makeGraphQLRequest';

export interface User {
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function fetchAllUsers(client: GraphQLClient): Promise<User[]> {
/** List */
nodes: User[];
};
}>(client, TEAMS, {
}>(client, USERS, {
first: PAGE_SIZE,
offset,
});
Expand Down
4 changes: 4 additions & 0 deletions src/graphql/gqls/dataPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export const UPDATE_OR_CREATE_DATA_POINT = gql`
$path: [String!]
$title: String
$description: String
$ownerIds: [ID!]
$teamIds: [ID!]
$dataCollectionTag: String
$querySuggestions: [DbIntegrationQuerySuggestionInput!]
$enabledActions: [RequestActionObjectResolver!]
Expand All @@ -114,6 +116,8 @@ export const UPDATE_OR_CREATE_DATA_POINT = gql`
title: $title
dataCollectionTag: $dataCollectionTag
description: $description
ownerIds: $ownerIds
teamIds: $teamIds
querySuggestions: $querySuggestions
enabledActions: $enabledActions
subDataPoints: $subDataPoints
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/gqls/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export const USERS = gql`
query TranscendCliUsers(
$first: Int!
$offset: Int!
$input: TeamFiltersInput
$input: UserFiltersInput
) {
users(
first: $first
offset: $offset
filterBy: $input
orderBy: [
{ field: createdAt, direction: ASC }
{ field: email, direction: ASC }
{ field: name, direction: ASC }
]
) {
nodes {
Expand Down
11 changes: 5 additions & 6 deletions src/graphql/syncDataSilos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { GraphQLClient } from 'graphql-request';
import { logger } from '../logger';
import colors from 'colors';
import { mapSeries, map } from 'bluebird';
import keyBy from 'lodash/keyBy';
import {
DATA_SILOS,
CREATE_DATA_SILOS,
Expand Down Expand Up @@ -38,7 +37,7 @@ import { makeGraphQLRequest } from './makeGraphQLRequest';
import { apply } from '@transcend-io/type-utils';
import { fetchAllUsers } from './fetchAllUsers';
import { fetchAllTeams } from './fetchAllTeams';
import { pickBy } from 'lodash';
import { keyBy } from 'lodash';

export interface DataSiloAttributeValue {
/** Key associated to value */
Expand Down Expand Up @@ -799,11 +798,11 @@ export async function syncDataSilos(
let teamNameToTeamId: { [k in string]: string } = {};
if (ownerEmails.length > 0) {
const users = await fetchAllUsers(client);
emailToUserId = apply(pickBy(users, 'email'), ({ id }) => id);
emailToUserId = apply(keyBy(users, 'email'), ({ id }) => id);
}
if (teamNames.length > 0) {
const teams = await fetchAllTeams(client);
teamNameToTeamId = apply(pickBy(teams, 'name'), ({ id }) => id);
teamNameToTeamId = apply(keyBy(teams, 'name'), ({ id }) => id);
}

await map(
Expand Down Expand Up @@ -856,14 +855,14 @@ export async function syncDataSilos(
description: datapoint.description,
...(datapoint.owners
? {
owners: datapoint.owners
ownerIds: datapoint.owners
.map((email) => emailToUserId[email])
.filter((x) => !!x),
}
: {}),
...(datapoint.teams
? {
teams: datapoint.teams
teamIds: datapoint.teams
.map((name) => teamNameToTeamId[name])
.filter((x) => !!x),
}
Expand Down

0 comments on commit 5839716

Please sign in to comment.