Skip to content

Commit 9d519a7

Browse files
Added Equalified as a filterable status, de-duplicating tags
1 parent 034928a commit 9d519a7

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/routes/getFilters.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export const getFilters = async ({ request, reply }) => {
2929
tags: response.tags.map(obj => ({ ...obj, type: 'tags' })),
3030
properties: response.properties.map(obj => ({ ...obj, type: 'properties' })),
3131
urls: response.urls.map(obj => ({ ...obj, type: 'urls' })),
32-
statuses: [{ label: 'Active', value: 'active' }],
32+
statuses: [
33+
{ label: 'Active', value: 'active', type: 'status' },
34+
{ label: 'Equalified', value: 'equalified', type: 'status' },
35+
],
3336
},
3437
};
3538
}

src/routes/getResultsAll.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ export const getResultsAll = async ({ request, reply }) => {
6464
formattedMessages[message.message.id][message.node.equalified ? 'equalifiedCount' : 'activeCount'] += 1;
6565
}
6666

67+
const formattedTags = {};
68+
for (const tag of response.data.nodes
69+
.map(obj => obj.messageNodes).flat()
70+
.map(obj => obj.message.messageTags).flat().map(obj => obj.tag)) {
71+
if (!formattedTags?.[tag.tag]) {
72+
formattedTags[tag.tag] = {
73+
id: tag.id,
74+
tag: tag.tag,
75+
};
76+
}
77+
}
78+
6779
const formattedChart = {};
6880
for (const node of response.data.nodes) {
6981
const date = node.createdAt.split('T')[0];
@@ -93,13 +105,7 @@ export const getResultsAll = async ({ request, reply }) => {
93105
...obj,
94106
totalCount: obj.equalifiedCount + obj.activeCount,
95107
})),
96-
tags: response.data.nodes
97-
.map(obj => obj.messageNodes).flat()
98-
.map(obj => obj.message.messageTags).flat()
99-
.map(obj => ({
100-
id: obj.tag.id,
101-
tag: obj.tag.tag,
102-
})),
108+
tags: Object.values(formattedTags),
103109
chart: Object.values(formattedChart)
104110
.sort((a, b) => a.date > b.date ? -1 : 1),
105111
};

0 commit comments

Comments
 (0)