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

inclusion-numerique / coop-mediation-numerique / e54bb7f1-0236-4207-bf15-3fc4e5393707

03 Feb 2026 03:34PM UTC coverage: 10.45% (+3.1%) from 7.372%
e54bb7f1-0236-4207-bf15-3fc4e5393707

push

circleci

hugues-m
chore: disable siret integration test / api times out

610 of 9672 branches covered (6.31%)

Branch coverage included in aggregate %.

1963 of 14950 relevant lines covered (13.13%)

1.8 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

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

9
const filterByDateRange =
10
  (from: Date, to?: Date) => (thread: { updated: Date }) =>
×
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"
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
}[] => {
27
  const now = _internal?.now ?? new Date()
×
28

29
  const startOfToday = startOfDay(now)
×
30

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

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

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

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
    },
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