skander101 commited on
Commit
3bb0198
·
1 Parent(s): affc728

fix: sort date groups by published_iso (YYYY-MM-DD) instead of display string

Browse files
frontend/dist/assets/index-Cq8JVj-_.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>News Digest</title>
7
  <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:ital,wght@0,400;0,600;0,700;1,400&family=Lora:wght@400;600;700&display=swap" rel="stylesheet">
8
- <script type="module" crossorigin src="/assets/index-QQ_dLdH2.js"></script>
9
  <link rel="stylesheet" crossorigin href="/assets/index-DI9qLnC9.css">
10
  </head>
11
  <body>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>News Digest</title>
7
  <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:ital,wght@0,400;0,600;0,700;1,400&family=Lora:wght@400;600;700&display=swap" rel="stylesheet">
8
+ <script type="module" crossorigin src="/assets/index-Cq8JVj-_.js"></script>
9
  <link rel="stylesheet" crossorigin href="/assets/index-DI9qLnC9.css">
10
  </head>
11
  <body>
frontend/src/App.jsx CHANGED
@@ -11,20 +11,22 @@ const CAT_LABELS = {
11
  }
12
 
13
  function groupByDate(clusters) {
 
 
14
  const map = {}
15
  for (const c of clusters) {
16
- const d = c.articles[0]?.published || 'Unknown'
17
- if (!map[d]) map[d] = []
18
- map[d].push(c)
19
  }
20
  const sorted = Object.entries(map).sort((a, b) => {
21
- if (a[0] === 'Unknown') return 1
22
- if (b[0] === 'Unknown') return -1
23
  return b[0].localeCompare(a[0])
24
  })
25
- return sorted.map(([date, items]) => ({
26
- date,
27
- items: items.sort((a, b) => (b.final_score || 0) - (a.final_score || 0)),
28
  }))
29
  }
30
 
 
11
  }
12
 
13
  function groupByDate(clusters) {
14
+ const getDate = (c) => c.articles[0]?.published_iso || ''
15
+ const getDisplay = (c) => c.articles[0]?.published || 'Unknown'
16
  const map = {}
17
  for (const c of clusters) {
18
+ const key = getDate(c)
19
+ if (!map[key]) map[key] = { display: getDisplay(c), items: [] }
20
+ map[key].items.push(c)
21
  }
22
  const sorted = Object.entries(map).sort((a, b) => {
23
+ if (!a[0]) return 1
24
+ if (!b[0]) return -1
25
  return b[0].localeCompare(a[0])
26
  })
27
+ return sorted.map(([, group]) => ({
28
+ date: group.display,
29
+ items: group.items.sort((a, b) => (b.final_score || 0) - (a.final_score || 0)),
30
  }))
31
  }
32