• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

inclusion-numerique / coop-mediation-numerique / 240dc2e0-7f8b-417f-9969-2331dc3cf6e8

01 Apr 2026 04:06PM UTC coverage: 10.684% (+3.7%) from 6.94%
240dc2e0-7f8b-417f-9969-2331dc3cf6e8

push

circleci

web-flow
Merge pull request #469 from inclusion-numerique/dev

MEP 2026-01-01

709 of 10542 branches covered (6.73%)

Branch coverage included in aggregate %.

25 of 399 new or added lines in 37 files covered. (6.27%)

820 existing lines in 91 files now uncovered.

2174 of 16443 relevant lines covered (13.22%)

2.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/web/src/assistant/groupChatThreadsByPeriod.ts
1
import type { UserChatThreadsList } from '@app/web/assistant/getChatThread'
2

UNCOV
3
const startOfDay = (date: Date): Date => {
×
UNCOV
4
  const d = new Date(date)
×
UNCOV
5
  d.setHours(0, 0, 0, 0)
×
UNCOV
6
  return d
×
7
}
8

9
const filterByDateRange =
UNCOV
10
  (from: Date, to?: Date) => (thread: { updated: Date }) =>
×
UNCOV
11
    to ? thread.updated >= from && thread.updated < to : thread.updated >= from
×
12

13
// Groupe les messages pour la sidebar
14
// "Aujourd'hui
15
// "Hier
16
// "7 derniers jours"
17
// "30 derniers jours"
UNCOV
18
export const groupChatThreadsByPeriod = <
×
19
  T extends Pick<UserChatThreadsList[number], 'updated'>,
20
>(
21
  chatThreadHistory: T[],
22
  _internal?: { now: Date }, // for testing only
23
): {
24
  period: string
25
  threads: T[]
26
}[] => {
UNCOV
27
  const now = _internal?.now ?? new Date()
×
28

UNCOV
29
  const startOfToday = startOfDay(now)
×
30

UNCOV
31
  const startOfYesterday = new Date(startOfToday)
×
UNCOV
32
  startOfYesterday.setDate(startOfYesterday.getDate() - 1)
×
33

UNCOV
34
  const startOf7DaysAgo = new Date(startOfToday)
×
UNCOV
35
  startOf7DaysAgo.setDate(startOf7DaysAgo.getDate() - 7)
×
36

UNCOV
37
  const startOf30DaysAgo = new Date(startOfToday)
×
UNCOV
38
  startOf30DaysAgo.setDate(startOf30DaysAgo.getDate() - 30)
×
39

UNCOV
40
  return [
×
41
    {
42
      period: 'Aujourd’hui',
43
      threads: chatThreadHistory.filter(filterByDateRange(startOfToday)),
44
    },
45
    {
46
      period: 'Hier',
47
      threads: chatThreadHistory.filter(
48
        filterByDateRange(startOfYesterday, startOfToday),
49
      ),
50
    },
51
    {
52
      period: '7 derniers jours',
53
      threads: chatThreadHistory.filter(
54
        filterByDateRange(startOf7DaysAgo, startOfYesterday),
55
      ),
56
    },
57
    {
58
      period: '30 derniers jours',
59
      threads: chatThreadHistory.filter(
60
        filterByDateRange(startOf30DaysAgo, startOf7DaysAgo),
61
      ),
62
    },
63
    {
64
      period: 'Précédents',
65
      threads: chatThreadHistory.filter(
66
        filterByDateRange(new Date(0), startOf30DaysAgo),
67
      ),
68
    },
UNCOV
69
  ].filter(({ threads }) => threads.length > 0)
×
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc