File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 273273 < a-menu-item key ="default "> {{ i18n "default" }}</ a-menu-item >
274274 < a-menu-item key ="alphabet "> {{ i18n "alphabet" }}</ a-menu-item >
275275 < a-menu-item key ="remainingTime "> {{ i18n "remained" }}</ a-menu-item >
276+ < a-menu-item key ="usage "> {{ i18n "usage" }}</ a-menu-item >
276277 </ a-menu >
277278 </ a-dropdown >
278279 </ a-col >
13721373 const sortBy = this . clientSortBy || 'default' ;
13731374 if ( sortBy === 'alphabet' ) {
13741375 return clients . sort ( ( a , b ) => a . email . localeCompare ( b . email ) ) ;
1376+ } else if ( sortBy === 'usage' ) {
1377+ return clients . sort ( ( a , b ) => {
1378+ const aStat = dbInbound . clientStats . find ( s => s . email === a . email ) || { up : 0 , down : 0 } ;
1379+ const bStat = dbInbound . clientStats . find ( s => s . email === b . email ) || { up : 0 , down : 0 } ;
1380+ const aUsage = ( aStat . up || 0 ) + ( aStat . down || 0 ) ;
1381+ const bUsage = ( bStat . up || 0 ) + ( bStat . down || 0 ) ;
1382+ if ( bUsage !== aUsage ) {
1383+ return bUsage - aUsage ;
1384+ }
1385+ return ( a . email || '' ) . localeCompare ( b . email || '' ) ;
1386+ } ) ;
13751387 } else if ( sortBy === 'remainingTime' ) {
13761388 return clients . sort ( ( a , b ) => {
13771389 const aStat = dbInbound . clientStats . find ( s => s . email === a . email ) || { expiryTime : 0 } ;
You can’t perform that action at this time.
0 commit comments