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
4 changes: 2 additions & 2 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const uniqueifyArray = <T>(array: T[]): T[] => {
return [...new Set(array)];
};

export /**
/**
* Remove duplicate values from an array of objects per unique key
*
* @template T
Expand All @@ -110,7 +110,7 @@ export /**
* @param {(item: T, index: number, uniqueKey: string) => R} [processItem] Optional function to process the item before adding it to the result array
* @return {*} {R[]}
*/
const uniqueifyObjectArray = <T, R = T>(
export const uniqueifyObjectArray = <T, R = T>(
array: T[],
uniqueKey: (item: T) => string,
processItem?: (item: T, index: number, uniqueKey: string) => R,
Expand Down
10 changes: 6 additions & 4 deletions src/schema/opportunity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getBufferFromStream,
toGQLEnum,
uniqueifyArray,
uniqueifyObjectArray,
updateFlagsStatement,
} from '../common';
import {
Expand Down Expand Up @@ -166,7 +167,7 @@ export interface GQLOpportunityPreviewResult {
totalCount: number;
tags: string[] | null;
companies: Array<{ name: string; favicon?: string }> | null;
squads: string[] | null;
squads: GQLSource[] | null;
}

export interface GQLOpportunityPreviewConnection {
Expand Down Expand Up @@ -463,7 +464,7 @@ export const typeDefs = /* GraphQL */ `
type OpportunityPreviewResult {
tags: [String!]!
companies: [OpportunityPreviewCompany!]!
squads: [String!]!
squads: [Source!]!
totalCount: Int
}

Expand Down Expand Up @@ -1282,10 +1283,11 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<

const companies = getShowcaseCompanies();

const squads = uniqueifyArray(
const squads = uniqueifyObjectArray(
connection.edges.flatMap(({ node }) =>
(node.activeSquads || []).map((squad) => squad.id),
(node.activeSquads || []).map((squad) => squad),
),
(squad) => squad.handle,
);

return {
Expand Down
Loading