|
|
|
@ -61,11 +61,11 @@ export function createQuestionWithAggregateData(
|
|
|
|
|
),
|
|
|
|
|
content: data.content,
|
|
|
|
|
id: data.id,
|
|
|
|
|
lastSeenAt: data.lastSeenAt,
|
|
|
|
|
numAnswers: data._count.answers,
|
|
|
|
|
numComments: data._count.comments,
|
|
|
|
|
numVotes: votes,
|
|
|
|
|
receivedCount: data.encounters.length,
|
|
|
|
|
seenAt: data.encounters[0].seenAt,
|
|
|
|
|
type: data.questionType,
|
|
|
|
|
updatedAt: data.updatedAt,
|
|
|
|
|
user: data.user?.name ?? '',
|
|
|
|
@ -80,12 +80,7 @@ export function createAggregatedQuestionEncounter(
|
|
|
|
|
const companyCounts: Record<string, number> = {};
|
|
|
|
|
const roleCounts: Record<string, number> = {};
|
|
|
|
|
|
|
|
|
|
let latestSeenAt = encounters[0].seenAt;
|
|
|
|
|
|
|
|
|
|
for (const encounter of encounters) {
|
|
|
|
|
latestSeenAt =
|
|
|
|
|
latestSeenAt < encounter.seenAt ? encounter.seenAt : latestSeenAt;
|
|
|
|
|
|
|
|
|
|
if (encounter.company !== null) {
|
|
|
|
|
if (!(encounter.company.name in companyCounts)) {
|
|
|
|
|
companyCounts[encounter.company!.name] = 0;
|
|
|
|
@ -137,7 +132,6 @@ export function createAggregatedQuestionEncounter(
|
|
|
|
|
return {
|
|
|
|
|
companyCounts,
|
|
|
|
|
countryCounts,
|
|
|
|
|
latestSeenAt,
|
|
|
|
|
roleCounts,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|