data/FolderSuggestion.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QList> | ||
| 4 | #include <QPair> | ||
| 5 | #include <QString> | ||
| 6 | #include <cmath> | ||
| 7 | |||
| 8 | // Raw mailbox paths are action identities, never parsed from display labels. | ||
| 9 | struct FolderSuggestion { | ||
| 10 | using Candidate = QPair<QString, double>; | ||
| 11 | Candidate primary; | ||
| 12 | Candidate alternate; | ||
| 13 | // Sprint 105 S105.3.2/S105.3.8: the display threshold chosen by the | ||
| 14 | // replay of the user's filings (0.4 for the older word model), and why | ||
| 15 | // the primary was suggested: the evidence kind (FolderEvidence::Kind; | ||
| 16 | // 0 = word model, 6 = the server's spam filter) and its counts. The | ||
| 17 | // interface words it at display time. | ||
| 18 | enum Reason { NoReason = 0, Thread = 1, List = 2, Sender = 3, Alias = 4, Subject = 5, SpamFilter = 6 }; | ||
| 19 | double threshold = 0.4; | ||
| 20 | int reason = NoReason; | ||
| 21 | int support = 0; | ||
| 22 | int total = 0; | ||
| 23 | |||
| 24 | 3354 | static FolderSuggestion fromScores(const QList<Candidate> &scores, | |
| 25 | bool spam, const QString &junkFolder) { | ||
| 26 | 3354 | FolderSuggestion result; | |
| 27 | // Preserve the existing classifier's insufficient-training behavior. | ||
| 28 |
2/2✓ Branch 3 → 4 taken 292 times.
✓ Branch 3 → 5 taken 3062 times.
|
3354 | if (scores.isEmpty()) return result; |
| 29 | 5884 | const auto valid = [](const Candidate &value) { | |
| 30 |
3/4✓ Branch 5 → 6 taken 5884 times.
✗ Branch 5 → 11 not taken.
✓ Branch 7 → 8 taken 5883 times.
✓ Branch 7 → 11 taken 1 time.
|
17652 | return !value.first.isEmpty() && value.first.size() <= 4096 && |
| 31 |
3/6✓ Branch 3 → 4 taken 5884 times.
✗ Branch 3 → 11 not taken.
✓ Branch 8 → 9 taken 5883 times.
✗ Branch 8 → 11 not taken.
✓ Branch 9 → 10 taken 5883 times.
✗ Branch 9 → 11 not taken.
|
17652 | std::isfinite(value.second) && value.second >= 0 && value.second <= 1; |
| 32 | }; | ||
| 33 |
2/2✓ Branch 7 → 8 taken 3061 times.
✓ Branch 7 → 10 taken 1 time.
|
3062 | if (valid(scores.first())) result.primary = scores.first(); |
| 34 |
5/6✓ Branch 11 → 12 taken 2822 times.
✓ Branch 11 → 16 taken 240 times.
✓ Branch 14 → 15 taken 2822 times.
✗ Branch 14 → 16 not taken.
✓ Branch 17 → 18 taken 2822 times.
✓ Branch 17 → 20 taken 240 times.
|
3062 | if (scores.size() > 1 && valid(scores[1])) result.alternate = scores[1]; |
| 35 |
7/10✓ Branch 20 → 21 taken 4 times.
✓ Branch 20 → 31 taken 3058 times.
✓ Branch 22 → 23 taken 4 times.
✗ Branch 22 → 31 not taken.
✓ Branch 24 → 25 taken 4 times.
✗ Branch 24 → 31 not taken.
✓ Branch 26 → 27 taken 4 times.
✗ Branch 26 → 30 not taken.
✓ Branch 32 → 33 taken 3 times.
✓ Branch 32 → 38 taken 3059 times.
|
3070 | if (spam && !junkFolder.isEmpty() && junkFolder.size() <= 4096 && |
| 36 |
3/4✓ Branch 27 → 28 taken 1 time.
✓ Branch 27 → 30 taken 3 times.
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 31 taken 1 time.
|
9 | (result.primary.first.isEmpty() || result.primary.second < 0.98 || |
| 37 | 1 | result.primary.first == junkFolder)) { | |
| 38 | 3 | result.primary = {junkFolder, qMax(result.primary.second, 0.95)}; | |
| 39 | } | ||
| 40 | 3062 | return result; | |
| 41 | } | ||
| 42 | |||
| 43 | 12256 | Candidate visible(const QString &sourceFolder, bool useAlternate = false) const { | |
| 44 |
7/8✓ Branch 2 → 3 taken 270 times.
✓ Branch 2 → 9 taken 11986 times.
✓ Branch 4 → 5 taken 270 times.
✗ Branch 4 → 9 not taken.
✓ Branch 5 → 6 taken 269 times.
✓ Branch 5 → 9 taken 1 time.
✓ Branch 10 → 11 taken 268 times.
✓ Branch 10 → 12 taken 11988 times.
|
12525 | if (useAlternate && !alternate.first.isEmpty() && alternate.second >= 0.01 && |
| 45 |
2/2✓ Branch 7 → 8 taken 268 times.
✓ Branch 7 → 9 taken 1 time.
|
537 | alternate.first != sourceFolder) return alternate; |
| 46 |
6/6✓ Branch 13 → 14 taken 7626 times.
✓ Branch 13 → 18 taken 4362 times.
✓ Branch 14 → 15 taken 7422 times.
✓ Branch 14 → 18 taken 204 times.
✓ Branch 19 → 20 taken 7341 times.
✓ Branch 19 → 21 taken 4647 times.
|
19410 | if (!primary.first.isEmpty() && primary.second >= threshold && |
| 47 |
2/2✓ Branch 16 → 17 taken 7341 times.
✓ Branch 16 → 18 taken 81 times.
|
14763 | primary.first != sourceFolder) return primary; |
| 48 | 4647 | return {}; | |
| 49 | } | ||
| 50 | }; | ||
| 51 |