@@ -43,6 +43,8 @@ export async function useAllTabListSummary(sortingBy: SortingBy): Promise<Overal
4343 return new Date ( a . date ) . valueOf ( ) - new Date ( b . date ) . valueOf ( ) ;
4444 } ) ;
4545
46+ const mostDayExceptToday = fillMostListWithoutToday ( days ) ;
47+
4648 const firstDay = new Date ( days [ 0 ] . date ) ;
4749 const activeDaysTotal = days . length ;
4850
@@ -70,23 +72,18 @@ export async function useAllTabListSummary(sortingBy: SortingBy): Promise<Overal
7072 const averageTimeByActiveDays = Math . round ( summaryTime / activeDaysTotal ) ;
7173 const daysTotal = daysBetween ( firstDay , new Date ( days [ days . length - 1 ] . date ) ) ;
7274
73- const sortedByTimeDays = days . sort ( function ( a , b ) {
74- return a . summary - b . summary ;
75- } ) ;
75+ const mostDay = fillMostList ( days ) ;
7676
77- const mostActiveDay = sortedByTimeDays [ 0 ] ;
78- const mostActiveDayObj = fillMostDay ( mostActiveDay ) ;
79-
80- const mostInactiveDay = sortedByTimeDays [ sortedByTimeDays . length - 1 ] ;
81- const mostInactiveDayObj = fillMostDay ( mostInactiveDay ) ;
8277 return {
8378 firstDay : firstDay ,
8479 daysTotal : daysTotal ,
8580 activeDaysTotal : activeDaysTotal ,
8681 todaySummaryTime : todaySummaryTime ,
8782 averageTimeByActiveDays : averageTimeByActiveDays ,
88- mostActiveDay : mostActiveDayObj ,
89- mostInactiveDay : mostInactiveDayObj ,
83+ mostActiveDay : mostDay . mostActiveDayObj ,
84+ mostInactiveDay : mostDay . mostInactiveDayObj ,
85+ mostActiveDayExceptToday : mostDayExceptToday . mostActiveDayObjExceptToday ,
86+ mostInactiveDayExceptToday : mostDayExceptToday . mostInactiveDayObjExceptToday ,
9087 tabs : tabs ,
9188 summaryTime : summaryTime ,
9289 chart : {
@@ -102,3 +99,44 @@ function fillMostDay(mostDat: TabDay): ActiveDay {
10299 summaryTime : mostDat . summary ,
103100 } ;
104101}
102+
103+ function fillMostListWithoutToday ( days : TabDay [ ] ) {
104+ const daysWithoutToday = days
105+ . filter ( x => x . date != todayLocalDate ( ) )
106+ . sort ( function ( a , b ) {
107+ return new Date ( a . date ) . valueOf ( ) - new Date ( b . date ) . valueOf ( ) ;
108+ } ) ;
109+
110+ const sortedByTimeDaysWithoutToday = daysWithoutToday . sort ( function ( a , b ) {
111+ return a . summary - b . summary ;
112+ } ) ;
113+
114+ const mostActiveDayExceptToday = sortedByTimeDaysWithoutToday [ 0 ] ;
115+ const mostActiveDayObjExceptToday = fillMostDay ( mostActiveDayExceptToday ) ;
116+
117+ const mostInactiveDayExceptToday =
118+ sortedByTimeDaysWithoutToday [ sortedByTimeDaysWithoutToday . length - 1 ] ;
119+ const mostInactiveDayObjExceptToday = fillMostDay ( mostInactiveDayExceptToday ) ;
120+
121+ return {
122+ mostActiveDayObjExceptToday,
123+ mostInactiveDayObjExceptToday,
124+ } ;
125+ }
126+
127+ function fillMostList ( days : TabDay [ ] ) {
128+ const sortedByTimeDays = days . sort ( function ( a , b ) {
129+ return a . summary - b . summary ;
130+ } ) ;
131+
132+ const mostActiveDay = sortedByTimeDays [ 0 ] ;
133+ const mostActiveDayObj = fillMostDay ( mostActiveDay ) ;
134+
135+ const mostInactiveDay = sortedByTimeDays [ sortedByTimeDays . length - 1 ] ;
136+ const mostInactiveDayObj = fillMostDay ( mostInactiveDay ) ;
137+
138+ return {
139+ mostActiveDayObj,
140+ mostInactiveDayObj,
141+ } ;
142+ }
0 commit comments