Skip to content

Commit 374c348

Browse files
authored
contact temperature score (#2468)
* Create 20251007133948_refinedpersons_add_coulmn_temperature_score.sql * Update 20251007133948_refinedpersons_add_coulmn_temperature_score.sql * update frontend * Update MiningTable.vue add i18n add temperature remove default occurence/ recency * Update MiningTable.vue * Update 20251007133948_refinedpersons_add_coulmn_temperature_score.sql
1 parent 4c35418 commit 374c348

File tree

3 files changed

+357
-4
lines changed

3 files changed

+357
-4
lines changed

frontend/src/components/Mining/Table/MiningTable.vue

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,39 @@
427427
</template>
428428
</Column>
429429

430+
<Column
431+
v-if="visibleColumns.includes('temperature')"
432+
field="temperature"
433+
data-type="numeric"
434+
sortable
435+
:show-filter-operator="false"
436+
:show-add-button="false"
437+
>
438+
<template #header>
439+
<div v-tooltip.top="t('temperature_definition')">
440+
{{ t('temperature') }}
441+
</div>
442+
</template>
443+
<template #filter="{ filterModel }">
444+
<InputNumber v-model="filterModel.value" />
445+
</template>
446+
<template #body="{ data }">
447+
<div
448+
v-if="data.temperature"
449+
class="flex items-center justify-center gap-3"
450+
>
451+
<div
452+
:style="getHeatColorStyle(data.temperature)"
453+
class="w-8 h-8 rounded-full text-xs font-bold text-white"
454+
>
455+
<span class="flex items-center justify-center w-full h-full">
456+
{{ data.temperature }}
457+
</span>
458+
</div>
459+
</div>
460+
</template>
461+
</Column>
462+
430463
<!-- Tags -->
431464
<Column
432465
v-if="visibleColumns.includes('tags')"
@@ -1054,6 +1087,7 @@ const visibleColumnsOptions = [
10541087
{ label: t('occurrence'), value: 'occurrence' },
10551088
{ label: t('recency'), value: 'recency' },
10561089
{ label: t('replies'), value: 'replied_conversations' },
1090+
{ label: t('temperature'), value: 'temperature' },
10571091
{ label: t('tags'), value: 'tags' },
10581092
{ label: t('reachable'), value: 'status' },
10591093
{ label: t('recipient'), value: 'recipient' },
@@ -1158,10 +1192,9 @@ onNuxtReady(async () => {
11581192
'same_as',
11591193
'telephone',
11601194
'image',
1161-
...($screenStore.width > 550 ? ['occurrence'] : []),
1162-
...($screenStore.width > 700 ? ['recency'] : []),
1163-
...($screenStore.width > 800 ? ['tags'] : []),
1164-
...($screenStore.width > 950 ? ['status'] : []),
1195+
'temperature',
1196+
...($screenStore.width > 550 ? ['tags'] : []),
1197+
...($screenStore.width > 700 ? ['status'] : []),
11651198
];
11661199
11671200
await $contactsStore.reloadContacts();
@@ -1189,6 +1222,32 @@ onUnmounted(() => {
11891222
$contactsStore.$reset();
11901223
scrollHeightObserver.value?.disconnect();
11911224
});
1225+
1226+
const getHeatColorStyle = (temp: number | null) => {
1227+
if (temp === null) return { backgroundColor: '#9ca3af' };
1228+
1229+
const normalizedTemperature = Math.min(Math.max(temp / 100, 0), 1);
1230+
1231+
if (normalizedTemperature < 0.3) {
1232+
// Cool blues
1233+
const temperatureRatio = normalizedTemperature / 0.3;
1234+
return {
1235+
backgroundColor: `hsl(${220 - temperatureRatio * 20}, 95%, ${55 - temperatureRatio * 10}%)`,
1236+
};
1237+
} else if (normalizedTemperature < 0.7) {
1238+
// Warm oranges/ambers - skipping green
1239+
const temperatureRatio = (normalizedTemperature - 0.3) / 0.4;
1240+
return {
1241+
backgroundColor: `hsl(${40 - temperatureRatio * 20}, 95%, ${50 - temperatureRatio * 5}%)`,
1242+
};
1243+
} else {
1244+
// Hot reds
1245+
const temperatureRatio = (normalizedTemperature - 0.7) / 0.3;
1246+
return {
1247+
backgroundColor: `hsl(${20 - temperatureRatio * 20}, 95%, ${45 - temperatureRatio * 10}%)`,
1248+
};
1249+
}
1250+
};
11921251
</script>
11931252

11941253
<style>
@@ -1256,6 +1315,8 @@ table.p-datatable-table {
12561315
"source": "Source",
12571316
"occurrence_definition": "Total occurrences of this contact",
12581317
"occurrence": "Occurrence",
1318+
"temperature_definition": "The hotter, the more replies, recent activity, and engagement — and a higher chance of future replies.",
1319+
"temperature": "Temperature",
12591320
"recency": "Recency",
12601321
"recency_definition": "When was the last time this contact was seen",
12611322
"replies_definition": "How many times this contact replied",
@@ -1308,6 +1369,8 @@ table.p-datatable-table {
13081369
"source": "Source",
13091370
"occurence_definition": "Occurrences totales de ce contact",
13101371
"occurrence": "Occurrence",
1372+
"temperature_definition": "Plus la température est élevée, plus il y a de réponses, d'activité récente et d'engagement, et plus les chances d'obtenir des réponses futures sont élevées.",
1373+
"temperature": "Temperature",
13111374
"recency": "Récence",
13121375
"recency_definition": "Dernière fois que ce contact a été vu",
13131376
"replies_definition": "Nombre de réponses de ce contact",

frontend/src/types/contact.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface Contact {
3030
replied_conversations?: number;
3131
status: EmailStatus | null;
3232
occurrence?: number;
33+
temperature: number | null;
3334
personid?: string;
3435
recency?: Date;
3536
seniority?: Date;

0 commit comments

Comments
 (0)