Courrier v1.2 (tt-2026-11-064) : tri du jour du plus recent au plus ancien, repartition par nombre de mails decroissant

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGaEeWkqZYNP6Wn3mGQsrL
This commit is contained in:
gemini-opsandClaude Sonnet 5.5 committed 2026-11-17 22:38:37 +01:00
1 parent 71262d927e
commit cdb78c3e04
3 files changed
+32 -6

No files matched your search

+4 -4
View File
@@ -119,7 +119,7 @@
if (jour !== S.jour) return; if (jour !== S.jour) return;
var r = rs[1]; var r = rs[1];
S.miroirErreur = !!r.miroir_erreur; S.miroirErreur = !!r.miroir_erreur;
S.mails = (r.mails || []).map(normaliser).sort(function (a, b) { return String(a.date).localeCompare(String(b.date)); }); S.mails = (r.mails || []).map(normaliser).sort(function (a, b) { return String(b.date).localeCompare(String(a.date)); });
S.etat = 'ok'; S.majHeure = heureTunis(new Date().toISOString()); S.etat = 'ok'; S.majHeure = heureTunis(new Date().toISOString());
rendre(); rendre();
}).catch(function (e) { if (e.message === 'session') return; if (jour !== S.jour) return; S.etat = 'erreur'; rendre(); }); }).catch(function (e) { if (e.message === 'session') return; if (jour !== S.jour) return; S.etat = 'erreur'; rendre(); });
@@ -350,7 +350,7 @@
var tous = S.mails, nbT = tous.filter(function (m) { return m.traite; }).length; var tous = S.mails, nbT = tous.filter(function (m) { return m.traite; }).length;
var compte = {}; tous.forEach(function (m) { compte[m.cat] = (compte[m.cat] || 0) + 1; }); var compte = {}; tous.forEach(function (m) { compte[m.cat] = (compte[m.cat] || 0) + 1; });
var puces = h('div', { class: 'puces', role: 'group', 'aria-label': 'Filtrer par catégorie' }); var puces = h('div', { class: 'puces', role: 'group', 'aria-label': 'Filtrer par catégorie' });
var defs = [{ nom: 'Tous', c: -1, n: tous.length, filtre: null }].concat(S.cats.map(function (c) { return { nom: c.nom, c: couleur(c.nom, c.id), n: compte[c.nom] || 0, filtre: c.nom }; })); var defs = [{ nom: 'Tous', c: -1, n: tous.length, filtre: null }].concat(S.cats.map(function (c, i) { return { nom: c.nom, c: couleur(c.nom, c.id), n: compte[c.nom] || 0, filtre: c.nom, rang: i }; }).sort(function (x, y) { return y.n - x.n || x.rang - y.rang; }));
defs.forEach(function (p) { defs.forEach(function (p) {
var actif = S.filtre === p.filtre; var actif = S.filtre === p.filtre;
puces.appendChild(h('button', { type: 'button', 'aria-pressed': actif ? 'true' : 'false', class: 'puce' + (p.c === 0 ? ' vide' : '') + (p.c > 0 ? ' t' + p.c : ''), onclick: function () { S.filtre = actif ? null : p.filtre; rendre(); } }, puces.appendChild(h('button', { type: 'button', 'aria-pressed': actif ? 'true' : 'false', class: 'puce' + (p.c === 0 ? ' vide' : '') + (p.c > 0 ? ' t' + p.c : ''), onclick: function () { S.filtre = actif ? null : p.filtre; rendre(); } },
@@ -444,8 +444,8 @@
var cc = {}, ce = {}; var cc = {}, ce = {};
G.mails.forEach(function (m) { cc[m.cat] = (cc[m.cat] || 0) + 1; (m.etiquettes || []).forEach(function (t) { ce[t] = (ce[t] || 0) + 1; }); }); G.mails.forEach(function (m) { cc[m.cat] = (cc[m.cat] || 0) + 1; (m.etiquettes || []).forEach(function (t) { ce[t] = (ce[t] || 0) + 1; }); });
var pc = h('div', { class: 'puces', role: 'group', 'aria-label': 'Catégorie' }); var pc = h('div', { class: 'puces', role: 'group', 'aria-label': 'Catégorie' });
S.cats.forEach(function (c) { S.cats.map(function (c, i) { return { c: c, rang: i }; }).sort(function (x, y) { return (cc[y.c.nom] || 0) - (cc[x.c.nom] || 0) || x.rang - y.rang; }).forEach(function (o) {
var k = couleur(c.nom, c.id), actif = G.cat === c.nom; var c = o.c, k = couleur(c.nom, c.id), actif = G.cat === c.nom;
pc.appendChild(h('button', { type: 'button', 'aria-pressed': actif ? 'true' : 'false', class: 'puce' + (k === 0 ? ' vide' : '') + (k > 0 ? ' t' + k : ''), onclick: function () { G.cat = actif ? null : c.nom; rendre(); } }, pc.appendChild(h('button', { type: 'button', 'aria-pressed': actif ? 'true' : 'false', class: 'puce' + (k === 0 ? ' vide' : '') + (k > 0 ? ' t' + k : ''), onclick: function () { G.cat = actif ? null : c.nom; rendre(); } },
h('span', { class: 'pt c' + k, 'aria-hidden': 'true' }), h('span', { text: c.nom }), h('span', { class: 'n', text: d2(cc[c.nom] || 0) }))); h('span', { class: 'pt c' + k, 'aria-hidden': 'true' }), h('span', { text: c.nom }), h('span', { class: 'n', text: d2(cc[c.nom] || 0) })));
}); });
+2 -2
View File
@@ -10,7 +10,7 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="/static/fonts.css"> <link rel="stylesheet" href="/static/fonts.css">
<link rel="stylesheet" href="/static/nyora.css"> <link rel="stylesheet" href="/static/nyora.css">
<link rel="stylesheet" href="/static/app.css?v=20261117c"> <link rel="stylesheet" href="/static/app.css?v=20261117d">
</head> </head>
<body> <body>
<div id="app" class="coque"> <div id="app" class="coque">
@@ -20,6 +20,6 @@
</div> </div>
<div id="calque"></div> <div id="calque"></div>
<div id="annonce" class="sr" role="status" aria-live="polite"></div> <div id="annonce" class="sr" role="status" aria-live="polite"></div>
<script src="/static/app.js?v=20261117c"></script> <script src="/static/app.js?v=20261117d"></script>
</body> </body>
</html> </html>
+26
View File
@@ -0,0 +1,26 @@
from pathlib import Path
STATIC = Path(__file__).resolve().parent.parent / "app" / "static"
def _js():
return (STATIC / "app.js").read_text(encoding="utf-8")
def test_tri_du_jour_du_plus_recent_au_plus_ancien():
"""Les mails du jour sont triés par date décroissante (b comparé à a)."""
js = _js()
assert "S.mails = (r.mails || []).map(normaliser).sort(function (a, b) { return String(b.date).localeCompare(String(a.date)); });" in js
assert "String(a.date).localeCompare(String(b.date))" not in js
def test_repartition_du_jour_par_nombre_de_mails_decroissant():
"""Tous reste en tête, puis catégories par nombre de mails décroissant, égalité = ordre d'origine."""
js = _js()
assert "return y.n - x.n || x.rang - y.rang;" in js
assert js.index("nom: 'Tous'") < js.index("y.n - x.n")
def test_groupes_categories_meme_classement():
js = _js()
assert "(cc[y.c.nom] || 0) - (cc[x.c.nom] || 0) || x.rang - y.rang" in js