Skip to content

Commit 39a5bb8

Browse files
authored
Merge pull request #50 from ksy36/issue/49/1
Fixes #49: Adds a slider to adjust the spam-filter threshold on demand
2 parents fa3fde4 + b2ad843 commit 39a5bb8

3 files changed

Lines changed: 96 additions & 1 deletion

File tree

server/frontend/src/components/Buckets/ReportPreviewRow.vue

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
>: {{ maybeTranslatedComments(report) }}
1616
</div>
1717
</td>
18+
<td class="wrap-none ml-validity-col">
19+
<span :class="validityClass(report.ml_valid_probability)">
20+
{{ validityLabel(report.ml_valid_probability) }}
21+
</span>
22+
<br />
23+
<small
24+
>{{
25+
(validityProbability(report.ml_valid_probability) * 100).toFixed(1)
26+
}}%</small
27+
>
28+
</td>
1829
<td>
1930
<img
2031
v-if="report.os === 'Linux'"
@@ -112,6 +123,29 @@ export default {
112123
113124
return report.comments;
114125
},
126+
validityLabel(mlValidProbability) {
127+
if (!mlValidProbability) {
128+
return "Unknown";
129+
}
130+
131+
return mlValidProbability >= 0.5 ? "Valid" : "Invalid";
132+
},
133+
validityProbability(mlValidProbability) {
134+
if (!mlValidProbability) {
135+
return 0;
136+
}
137+
138+
return mlValidProbability >= 0.5
139+
? mlValidProbability
140+
: 1 - mlValidProbability;
141+
},
142+
validityClass(mlValidProbability) {
143+
if (!mlValidProbability) {
144+
return "validity-unknown";
145+
}
146+
147+
return mlValidProbability >= 0.5 ? "validity-valid" : "validity-invalid";
148+
},
115149
},
116150
};
117151
</script>
@@ -138,4 +172,23 @@ export default {
138172
*/
139173
padding-bottom: 1.2em;
140174
}
175+
176+
.ml-validity-col {
177+
text-align: center;
178+
}
179+
180+
.validity-valid {
181+
color: #28a745;
182+
font-weight: bold;
183+
}
184+
185+
.validity-invalid {
186+
color: #dc3545;
187+
font-weight: bold;
188+
}
189+
190+
.validity-unknown {
191+
color: #6c757d;
192+
font-style: italic;
193+
}
141194
</style>

server/frontend/src/components/Buckets/View.vue

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@
9292
/>
9393
</td>
9494
</tr>
95+
<tr>
96+
<td>ML Valid Probability Filter</td>
97+
<td>
98+
<div class="ml-filter-container">
99+
<input
100+
type="range"
101+
min="0"
102+
max="1"
103+
step="0.05"
104+
v-model.number="mlValidThreshold"
105+
class="ml-slider"
106+
/>
107+
<span class="ml-threshold-value"
108+
>≥ {{ mlValidThreshold.toFixed(2) }}</span
109+
>
110+
</div>
111+
</td>
112+
</tr>
95113
</tbody>
96114
</table>
97115
<div class="table-responsive">
@@ -103,6 +121,7 @@
103121
<th>Date Reported</th>
104122
<th>URL</th>
105123
<th>User Comments</th>
124+
<th>ML Label</th>
106125
<th>Product</th>
107126
<th>ETP &amp; PBM</th>
108127
</tr>
@@ -194,6 +213,7 @@ export default {
194213
currentPage: 1,
195214
description: "",
196215
loading: true,
216+
mlValidThreshold: 0.8,
197217
reports: null,
198218
sortKeys: [...defaultSortKeys],
199219
totalPages: 1,
@@ -247,7 +267,7 @@ export default {
247267
query: JSON.stringify({
248268
op: "AND",
249269
comments__length__gt: 0,
250-
ml_valid_probability__gt: 0.95,
270+
ml_valid_probability__gt: this.mlValidThreshold,
251271
bucket_id: this.bucket.id,
252272
}),
253273
};
@@ -397,6 +417,10 @@ export default {
397417
currentPage() {
398418
this.fetch();
399419
},
420+
mlValidThreshold() {
421+
this.currentPage = 1;
422+
this.fetch();
423+
},
400424
sortKeys() {
401425
this.fetch();
402426
},
@@ -414,4 +438,17 @@ button[aria-expanded="true"] .bi-eye-fill {
414438
button[aria-expanded="false"] .bi-eye-slash-fill {
415439
display: none;
416440
}
441+
.ml-filter-container {
442+
display: flex;
443+
align-items: center;
444+
gap: 10px;
445+
}
446+
.ml-slider {
447+
flex: 1;
448+
max-width: 300px;
449+
}
450+
.ml-threshold-value {
451+
font-weight: bold;
452+
min-width: 60px;
453+
}
417454
</style>

server/frontend/src/components/PageNav.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ export default {
108108
},
109109
},
110110
watch: {
111+
initial(newVal) {
112+
if (newVal !== this.page) {
113+
this.page = newVal;
114+
}
115+
},
111116
page() {
112117
this.recalculate();
113118
},

0 commit comments

Comments
 (0)