From: Will Budicm Date: Sun, 3 Jan 2021 05:21:56 +0000 (+1100) Subject: Started work on VIEW_OVERRIDE's. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=210353508fff9faa20abc16308897b7cc9827ed8;p=LifeLog.git Started work on VIEW_OVERRIDE's. --- diff --git a/Current Development Check List.md b/Current Development Check List.md index 98c92ff..cfddcff 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -10,10 +10,11 @@ * Reset Whole View to page view, should still set the search option till it is ticked. * Unticking Keep in Session should be honored on next browsing. * Global view overrides. These get generated in the db if set on logon. And used instead of the normal view. + * Overrides must always show todays log entries, regardless of criteria. * VIEW_OVERRIDE_SYSLOGS={0/1}, anon if set 1-true, will hide older than today system logs. Doesn't affect category and keywords searches/views. * VIEW_OVERRIDE_WHERE={""/{your where clause}}, allows your own WHERE override. Doesn't affect category and keywords searches/views. * i.e. <>>, will show only these type of log entries. - * i.e. <>>, will show only logs less then 30 days old. + * i.e. < DATE('now','start of month', '-2 month')">>>, will show only logs from current last two months. * i.e. <>>, same as setting <>>. * Page section plugins. * Configured in main.cnf. diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index b89b9fc..9155ef0 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -46,6 +46,28 @@ America/Austin=America/Chicago America/Texas=America/Chicago >> +/* + Global view overrides. These get generated in the db if set on logon. And used instead of the normal data view. + Overrides must always show todays log entries, regardless of criteria. + Overrides don't affect category and keywords desired searches and views. They are mainly useful to filter out + the not required to see on the main pages. + NOTE - These settings AND on VW_LOG_WITH_EXCLUDES if they are set. VW_ prefix signifies, database view, + meaning this will be created. Based on the settings bellow you make. An interesting concept, don't you think? +*/ + +####################### +# VIEW_OVERRIDE_SYSLOGS overrides not to show system logs older than today. +# Default for 0, disabled. +<>> + +####################### +# VIEW_OVERRIDE_WHERE overrides what to, or not to select. +# Default is not being used. OLDER_THAN keyword translates to appropriate SQL. +# By either months, days, hours. From current time. +# i.e VIEW_OVERRIDE_WHERE, this instructs skip older then to months logs and all sys logs. +# i.e VIEW_OVERRIDE_WHERE=6>, this instructs skip all categories bellow and including sys logs.. +<>> + < 00|$RELEASE_VER = 2.1`LifeLog Application Version. diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 844df18..f572974 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -397,6 +397,7 @@ try{ if(!$curr_tables{Settings->VW_LOG}) { $db->do(Settings::createViewLOGStmt()) or LifeLogException -> throw("ERROR:".$@); } + # From 2.2+ if(!$curr_tables{Settings->VW_LOG_WITH_EXCLUDES}) { # To cover all possible situations, this test elses too. # As an older existing view might need to be recreated, to keep in synch. @@ -528,6 +529,28 @@ sub createPageViewExcludeSQL { } +sub createPageViewWhereOverrideSQL { + + my ($where,$days) = ("",0); + my $parse = $PAGE_EXCLUDES; + my @a = split('=',$parse); + if(scalar(@a)==2){ + $days = $a[0]; + $parse = $a[1]; + } + @a = split(',',$parse); + foreach (@a){ + $where .= " ID_CAT!=$_ AND"; + } + + if(Settings::isProgressDB()){$where = "WHERE $where AND a.date >= (timestamp 'now' - interval '24 hours')"} + else{$where = "WHERE $where AND a.date >= date('now', '-24 hour')"} + + + return Settings::createViewLOGStmt(Settings->VW_LOG_OVERRIDE_WHERE,$where); + +} + sub populate { diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index 43461a2..f9b8421 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -23,11 +23,24 @@ use experimental qw( switch ); # This is the default developer release key, replace on istallation. As it is not secure. use constant CIPHER_KEY => '95d7a85ba891da'; use constant CIPHER_PADDING => 'fe0a2b6a83e81f13a2d76ab104763773310df6b0a01c7cf9807b4b0ce2a02'; -# Default VIEW for all pages. + +# Default VIEW for all pages, it lists and sorts on all logs, super fast server side. use constant VW_LOG => 'VW_LOG'; -# Optional instructional VIEW from config file replacing above default. + +# Optional instructional VIEW from config file replacing VW_LOG. +# Filtering out by category ID certain specified entries. use constant VW_LOG_WITH_EXCLUDES => 'VW_LOG_WITH_EXCLUDES'; +# Optional instructional VIEW from config directly overriding the +# where clause for data being delivered for pages. +# This view will always return all last 24 hour entered log entries. +# This view AND's by extending on VW_LOG_WITH_EXCLUDES, if is also set, which is something to be aware. +# Otherwise, similar just replaces the VW_LOG to deliver pages. +# +use constant VW_LOG_OVERRIDE_WHERE => 'VW_LOG_OVR_WHERE'; + + + #DEFAULT SETTINGS HERE! our $RELEASE_VER = '2.1'; our $TIME_ZONE = 'Australia/Sydney';