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.
# 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
apiKeySearchCh to configure own private API keys
for reverse search via klicktel.de or search.ch

View File

@ -37,6 +37,7 @@
###########################################################################################################################
# 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
# now available for "delSeqDoublets"
# 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 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,
"TYPE" => 64,
@ -4203,10 +4204,10 @@ sub delseqdoubl_DoParse($) {
$rt = $rt+tv_interval($st);
# 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 ($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()}) {
($ndev,$nread,undef,undef,$nval) = split("_ESC_", $nr); # Werte des aktuellen Elements
$or = pop @sel; # das letzte Element der Liste
@ -4221,10 +4222,11 @@ sub delseqdoubl_DoParse($) {
$oor = pop @sel; # das vorletzte Element der Liste
$ooval = (split '_ESC_', $oor)[-1]; # Value des vorletzten Elements
if ($ndev.$nread ne $odev.$oread) {
push (@sel,$oor);
push (@sel,$or);
$i = 0; # neues Device/Reading in einer Periode -> ooor soll erhalten bleiben
push (@sel,$oor) if($oor);
push (@sel,$or) if($or);
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,$nr);
push (@warp,$or); # Array der zu löschenden Datensätze
@ -4254,10 +4256,11 @@ sub delseqdoubl_DoParse($) {
$rt = $rt+tv_interval($st);
}
} else {
push (@sel,$oor);
push (@sel,$or);
push (@sel,$oor) if($oor);
push (@sel,$or) if($or);
push (@sel,$nr);
}
$i++;
}
if(@sel && $opt =~ /adviceRemain/) {
# 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)
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 @retarray = ($opt =~ /adviceRemain/)?@remain:($opt =~ /adviceDelete/)?@todel:" ";
# splice(@retarray,$limit+10);
if ($utf8 && @retarray) {
$rowlist = Encode::encode_utf8(join('|', @retarray));
} elsif(@retarray) {