From: Frédéric Marchal Date: Sun, 28 Nov 2010 15:41:03 +0000 (+0000) Subject: Add an option to sort the topsites by time X-Git-Tag: v2.3.2~118 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70cab1a4f9ad559fc523a62174d8fd3d9af5b325;p=thirdparty%2Fsarg.git Add an option to sort the topsites by time This option is not identical to the dynamic sort as it selects the top sites from the entire list and only displays the requested number of entries. Then the dynamic sort only offers to sort the truncated list. --- diff --git a/ChangeLog b/ChangeLog index eda38c6..f7c8c78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ Nov-28-2010 Version 2.3.2-pre1 - Add support for sorttable.js (http://www.kryogenix.org/code/browser/sorttable/) to dynamically sort some tables (thanks to Éric). - Add the two command line options --lastlog and --keeplogs to set the number of reports to keep or to keep all the reports respectively (thanks to Emmanuel Lacour for the suggestion). - Report the user ID in the e-mail report. + - Add an option to sort the top sites by time. Sep-18-2010 Version 2.3.1 - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway. diff --git a/getconf.c b/getconf.c index 2640696..3d08446 100644 --- a/getconf.c +++ b/getconf.c @@ -168,6 +168,7 @@ struct sort_list topsite_sort[]= { {"BYTES",TOPSITE_SORT_BYTES}, {"CONNECT",TOPSITE_SORT_CONNECT}, + {"TIME",TOPSITE_SORT_TIME}, }; struct sort_list user_sort[]= diff --git a/include/conf.h b/include/conf.h index f3d4cb0..852212b 100755 --- a/include/conf.h +++ b/include/conf.h @@ -255,6 +255,7 @@ int mkstemps(char *template, int suffixlen); #define TOPSITE_SORT_REVERSE SORT_REVERSE #define TOPSITE_SORT_BYTES 0x0002UL #define TOPSITE_SORT_CONNECT 0x0004UL +#define TOPSITE_SORT_TIME 0x0008UL #define USER_SORT_REVERSE SORT_REVERSE #define USER_SORT_BYTES 0x0002UL diff --git a/sarg.conf b/sarg.conf index 6164f06..a2a6220 100644 --- a/sarg.conf +++ b/sarg.conf @@ -245,7 +245,7 @@ # #topsites_num 100 -# TAG: topsites_sort_order CONNECT|BYTES A|D +# TAG: topsites_sort_order CONNECT|BYTES|TIME A|D # Sort for topsites report, where A=Ascendent, D=Descendent # #topsites_sort_order CONNECT D diff --git a/topsites.c b/topsites.c index 98d76ae..0ae966e 100644 --- a/topsites.c +++ b/topsites.c @@ -155,8 +155,12 @@ void topsites(void) if((TopsitesSort & TOPSITE_SORT_CONNECT) != 0) { sortf="-k 1,1 -k 2,2"; - } else { + } else if((TopsitesSort & TOPSITE_SORT_BYTES) != 0) { sortf="-k 2,2 -k 1,1"; + } else if((TopsitesSort & TOPSITE_SORT_TIME) != 0) { + sortf="-k 3,3"; + } else { + sortf="-k 2,2 -k 1,1"; //default is BYTES } if((TopsitesSort & TOPSITE_SORT_REVERSE) != 0) { sortt="-r";