diff --git a/server.cjs b/server.cjs index 58188db..8485739 100644 --- a/server.cjs +++ b/server.cjs @@ -797,10 +797,10 @@ function viewerDashboard() { const activityLocationRows = db.prepare(` select date(occurred_at) as date, - country, - city, - region, - timezone, + coalesce(nullif(country, ''), '') as country, + coalesce(nullif(city, ''), '') as city, + coalesce(nullif(region, ''), '') as region, + coalesce(nullif(timezone, ''), '') as timezone, count(distinct visitor_id) as visitors from viewer_events where occurred_at >= ? @@ -810,7 +810,7 @@ function viewerDashboard() { or region != '' or (timezone != '' and timezone != 'Not shared') ) - group by date(occurred_at), country, city, region, timezone + group by date(occurred_at), coalesce(nullif(country, ''), ''), coalesce(nullif(city, ''), ''), coalesce(nullif(region, ''), ''), coalesce(nullif(timezone, ''), '') order by date asc, visitors desc `).all(thirtyDaysSince) @@ -821,7 +821,7 @@ function viewerDashboard() { .join(', ') if (!label) continue const current = locationsByDate.get(row.date) || [] - if (current.length < 4) current.push({ label, visitors: row.visitors || 0 }) + current.push({ label, visitors: row.visitors || 0 }) locationsByDate.set(row.date, current) } diff --git a/src/App.jsx b/src/App.jsx index 4836ff3..e7b925d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2129,11 +2129,13 @@ function MiniLineChart({ accent = 'text-fury-cyan', data, label, metric, stroke .join(', ')} ) : null} - {metric === 'locations' && hoveredPoint.location_labels?.length ? ( - - {hoveredPoint.location_labels - .map((location) => `${location.label} (${formatNumber(location.visitors)})`) - .join(', ')} + {metric === 'locations' ? ( + + {hoveredPoint.location_labels?.length + ? hoveredPoint.location_labels + .map((location) => `${location.label} (${formatNumber(location.visitors)})`) + .join(', ') + : 'No location labels stored for this day'} ) : null}