Skip to content

Commit

Permalink
Added Equalified as a filterable status, de-duplicating tags
Browse files Browse the repository at this point in the history
  • Loading branch information
heythisischris committed Jul 11, 2024
1 parent 034928a commit 9d519a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/routes/getFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const getFilters = async ({ request, reply }) => {
tags: response.tags.map(obj => ({ ...obj, type: 'tags' })),
properties: response.properties.map(obj => ({ ...obj, type: 'properties' })),
urls: response.urls.map(obj => ({ ...obj, type: 'urls' })),
statuses: [{ label: 'Active', value: 'active' }],
statuses: [
{ label: 'Active', value: 'active', type: 'status' },
{ label: 'Equalified', value: 'equalified', type: 'status' },
],
},
};
}
20 changes: 13 additions & 7 deletions src/routes/getResultsAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ export const getResultsAll = async ({ request, reply }) => {
formattedMessages[message.message.id][message.node.equalified ? 'equalifiedCount' : 'activeCount'] += 1;
}

const formattedTags = {};
for (const tag of response.data.nodes
.map(obj => obj.messageNodes).flat()
.map(obj => obj.message.messageTags).flat().map(obj => obj.tag)) {
if (!formattedTags?.[tag.tag]) {
formattedTags[tag.tag] = {
id: tag.id,
tag: tag.tag,
};
}
}

const formattedChart = {};
for (const node of response.data.nodes) {
const date = node.createdAt.split('T')[0];
Expand Down Expand Up @@ -93,13 +105,7 @@ export const getResultsAll = async ({ request, reply }) => {
...obj,
totalCount: obj.equalifiedCount + obj.activeCount,
})),
tags: response.data.nodes
.map(obj => obj.messageNodes).flat()
.map(obj => obj.message.messageTags).flat()
.map(obj => ({
id: obj.tag.id,
tag: obj.tag.tag,
})),
tags: Object.values(formattedTags),
chart: Object.values(formattedChart)
.sort((a, b) => a.date > b.date ? -1 : 1),
};
Expand Down

0 comments on commit 9d519a7

Please sign in to comment.