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

inclusion-numerique / coop-mediation-numerique / 04cc0826-5790-4e51-9797-d08d3360efb5

08 Apr 2026 12:12PM UTC coverage: 10.614% (+3.1%) from 7.47%
04cc0826-5790-4e51-9797-d08d3360efb5

push

circleci

web-flow
Merge pull request #471 from inclusion-numerique/feat/quick-access

feat: quick access items

698 of 10544 branches covered (6.62%)

Branch coverage included in aggregate %.

0 of 5 new or added lines in 1 file covered. (0.0%)

932 existing lines in 96 files now uncovered.

2167 of 16449 relevant lines covered (13.17%)

1.95 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