diff --git a/src/components/ByDays.vue b/src/components/ByDays.vue index c59d6f4..b77c210 100644 --- a/src/components/ByDays.vue +++ b/src/components/ByDays.vue @@ -2,8 +2,10 @@
+
+
{{ t('noDataForPeriod.message') }} @@ -17,10 +19,11 @@ > + +
+
+ +
+
{{ t('averageTimeByDays.message') }}

{{ convertSummaryTimeToString(tabsByDays!.averageTime) }}

+
+
+ + + + -
@@ -77,6 +91,7 @@ import NoDataByDays from './NoDataByDays.vue'; import ByDaysChart from '../components/ByDaysChart.vue'; import Expander from '../components/Expander.vue'; import { TabListByDays } from '../dto/tabListSummary'; +import { CurrentTabItem } from '../dto/currentTabItem'; import { useTabListByDays } from '../functions/useTabListByDays'; import { convertSummaryTimeToString } from '../utils/converter'; import { ranges, ThisWeekRange } from '../utils/date'; @@ -131,6 +146,27 @@ async function exportToCsv() { `websites_${dateFrom.toLocaleDateString()}-${dateTo.toLocaleDateString()}.csv`, ); } + +function mergeAllDays(days: TabListByDays['days'] | undefined): CurrentTabItem[] { + if (!days) return []; + + const urlMap = new Map(); + + for (const day of days) { + for (const tab of day.tabs) { + if (!urlMap.has(tab.url)) { + urlMap.set(tab.url, { ...tab }); + continue; + } + + const existingTab = urlMap.get(tab.url)!; + existingTab.summaryTime += tab.summaryTime; + existingTab.sessions += tab.sessions; + } + } + + return Array.from(urlMap.values()).sort((a, b) => b.summaryTime - a.summaryTime); +}