2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

93_DbRep: V7.5.5, minor corrections in delSeqDoublets

git-svn-id: https://svn.fhem.de/fhem/trunk@15987 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2018-01-25 14:28:09 +00:00
parent 42049d941c
commit 896160cf89
2 changed files with 23 additions and 15 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- change: 93_DbRep: V7.5.5, minor corrections in delSeqDoublets
- change: 72_FB_CALLMONITOR: new attribute apiKeyKlicktelDe and - change: 72_FB_CALLMONITOR: new attribute apiKeyKlicktelDe and
apiKeySearchCh to configure own private API keys apiKeySearchCh to configure own private API keys
for reverse search via klicktel.de or search.ch for reverse search via klicktel.de or search.ch

View File

@ -37,6 +37,7 @@
########################################################################################################################### ###########################################################################################################################
# Versions History: # Versions History:
# #
# 7.5.5 25.01.2018 minor change in delSeqDoublets
# 7.5.4 24.01.2018 delseqdoubl_DoParse reviewed to optimize memory usage, executeBeforeDump executeAfterDump # 7.5.4 24.01.2018 delseqdoubl_DoParse reviewed to optimize memory usage, executeBeforeDump executeAfterDump
# now available for "delSeqDoublets" # now available for "delSeqDoublets"
# 7.5.3 23.01.2018 new attribute "ftpDumpFilesKeep", version management added to FTP-usage # 7.5.3 23.01.2018 new attribute "ftpDumpFilesKeep", version management added to FTP-usage
@ -293,7 +294,7 @@ use Encode qw(encode_utf8);
sub DbRep_Main($$;$); sub DbRep_Main($$;$);
sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden
my $DbRepVersion = "7.5.4"; my $DbRepVersion = "7.5.5";
my %dbrep_col = ("DEVICE" => 64, my %dbrep_col = ("DEVICE" => 64,
"TYPE" => 64, "TYPE" => 64,
@ -4203,12 +4204,12 @@ sub delseqdoubl_DoParse($) {
$rt = $rt+tv_interval($st); $rt = $rt+tv_interval($st);
# Beginn Löschlogik, Zusammenstellen der löschenden DS (warping) # Beginn Löschlogik, Zusammenstellen der löschenden DS (warping)
# Die Arrays @remain, @sel enthalten die VERBLEIBENDEN Datensätze # Array @sel -> die VERBLEIBENDEN Datensätze, @warp -> die zu löschenden Datensätze
my (@sel,@warp); my (@sel,@warp);
my ($or,$oor,$odev,$oread,$oval,$ooval,$ndev,$nread,$nval); my ($or,$oor,$odev,$oread,$oval,$ooval,$ndev,$nread,$nval);
my $i = 0;
foreach my $nr (map { $_->[0]."_ESC_".$_->[1]."_ESC_".($_->[2] =~ s/ /_ESC_/r)."_ESC_".$_->[3] } @{$sth->fetchall_arrayref()}) { foreach my $nr (map { $_->[0]."_ESC_".$_->[1]."_ESC_".($_->[2] =~ s/ /_ESC_/r)."_ESC_".$_->[3] } @{$sth->fetchall_arrayref()}) {
($ndev,$nread,undef,undef,$nval) = split("_ESC_", $nr); # Werte des aktuellen Elements ($ndev,$nread,undef,undef,$nval) = split("_ESC_", $nr); # Werte des aktuellen Elements
$or = pop @sel; # das letzte Element der Liste $or = pop @sel; # das letzte Element der Liste
($odev,$oread,undef,undef,$oval) = split("_ESC_", $or); # Value des letzten Elements ($odev,$oread,undef,undef,$oval) = split("_ESC_", $or); # Value des letzten Elements
if (looks_like_number($oval) && $var) { # Varianz +- falls $val numerischer Wert if (looks_like_number($oval) && $var) { # Varianz +- falls $val numerischer Wert
@ -4221,13 +4222,14 @@ sub delseqdoubl_DoParse($) {
$oor = pop @sel; # das vorletzte Element der Liste $oor = pop @sel; # das vorletzte Element der Liste
$ooval = (split '_ESC_', $oor)[-1]; # Value des vorletzten Elements $ooval = (split '_ESC_', $oor)[-1]; # Value des vorletzten Elements
if ($ndev.$nread ne $odev.$oread) { if ($ndev.$nread ne $odev.$oread) {
push (@sel,$oor); $i = 0; # neues Device/Reading in einer Periode -> ooor soll erhalten bleiben
push (@sel,$or); push (@sel,$oor) if($oor);
push (@sel,$or) if($or);
push (@sel,$nr); push (@sel,$nr);
} elsif (($ooval eq $oval && $oval eq $nval) || ($var1 && $var2 && ($ooval <= $var1) && ($var2 <= $ooval) && ($nval <= $var1) && ($var2 <= $nval)) ) { } elsif ($i>=2 && ($ooval eq $oval && $oval eq $nval) || ($i>=2 && $var1 && $var2 && ($ooval <= $var1) && ($var2 <= $ooval) && ($nval <= $var1) && ($var2 <= $nval)) ) {
push (@sel,$oor); push (@sel,$oor);
push (@sel,$nr); push (@sel,$nr);
push (@warp,$or); # Array der zu löschenden Datensätze push (@warp,$or); # Array der zu löschenden Datensätze
if ($opt =~ /delete/ && $or) { # delete Datensätze if ($opt =~ /delete/ && $or) { # delete Datensätze
my ($dev,$read,$date,$time,$val) = split("_ESC_", $or); my ($dev,$read,$date,$time,$val) = split("_ESC_", $or);
my $dt = $date." ".$time; my $dt = $date." ".$time;
@ -4252,12 +4254,13 @@ sub delseqdoubl_DoParse($) {
$dbh->commit() if(!$dbh->{AutoCommit}); $dbh->commit() if(!$dbh->{AutoCommit});
$rt = $rt+tv_interval($st); $rt = $rt+tv_interval($st);
} }
} else { } else {
push (@sel,$oor); push (@sel,$oor) if($oor);
push (@sel,$or); push (@sel,$or) if($or);
push (@sel,$nr); push (@sel,$nr);
} }
$i++;
} }
if(@sel && $opt =~ /adviceRemain/) { if(@sel && $opt =~ /adviceRemain/) {
# die verbleibenden Datensätze nach Ausführung (nur zur Anzeige) # die verbleibenden Datensätze nach Ausführung (nur zur Anzeige)
@ -4267,14 +4270,18 @@ sub delseqdoubl_DoParse($) {
# die zu löschenden Datensätze (nur zur Anzeige) # die zu löschenden Datensätze (nur zur Anzeige)
push(@todel,@warp) if($#todel+1 < $limit); push(@todel,@warp) if($#todel+1 < $limit);
} }
$nremain = $nremain + $#sel if(@sel);
$ntodel = $ntodel + $#warp if(@warp); $nremain = $nremain + $#sel+1 if(@sel);
$ntodel = $ntodel + $#warp+1 if(@warp);
my $sum = $nremain+$ntodel;
Log3 ($name, 3, "DbRep $name -> rows analyzed by \"$hash->{LASTCMD}\": $sum") if($sum && $opt =~ /advice/);
} }
Log3 ($name, 3, "DbRep $name -> rows deleted by \"$hash->{LASTCMD}\": $ndel") if($ndel);
my $retn = ($opt =~ /adviceRemain/)?$nremain:($opt =~ /adviceDelete/)?$ntodel:$ndel; my $retn = ($opt =~ /adviceRemain/)?$nremain:($opt =~ /adviceDelete/)?$ntodel:$ndel;
my @retarray = ($opt =~ /adviceRemain/)?@remain:($opt =~ /adviceDelete/)?@todel:" "; my @retarray = ($opt =~ /adviceRemain/)?@remain:($opt =~ /adviceDelete/)?@todel:" ";
# splice(@retarray,$limit+10);
if ($utf8 && @retarray) { if ($utf8 && @retarray) {
$rowlist = Encode::encode_utf8(join('|', @retarray)); $rowlist = Encode::encode_utf8(join('|', @retarray));
} elsif(@retarray) { } elsif(@retarray) {