Reformat Conf(TLH) for GroupStats only.
Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
		
							parent
							
								
									671ae67be0
								
							
						
					
					
						commit
						3447cdabff
					
				
					 2 changed files with 29 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -84,35 +84,6 @@ my ($Period) = &GetTimePeriod($OptMonth);
 | 
			
		|||
&Bleat(2,"--month option has an invalid format - please use 'YYYY-MM' or ".
 | 
			
		||||
         "'YYYY-MM:YYYY-MM'!") if (!$Period or $Period eq 'all time');
 | 
			
		||||
 | 
			
		||||
### reformat $Conf{'TLH'}
 | 
			
		||||
my $TLH;
 | 
			
		||||
if ($Conf{'TLH'}) {
 | 
			
		||||
  # $Conf{'TLH'} is parsed as an array by Config::Auto;
 | 
			
		||||
  # make a flat list again, separated by :
 | 
			
		||||
  if (ref($Conf{'TLH'}) eq 'ARRAY') {
 | 
			
		||||
    $TLH = join(':',@{$Conf{'TLH'}});
 | 
			
		||||
  } else {
 | 
			
		||||
    $TLH  = $Conf{'TLH'};
 | 
			
		||||
  }
 | 
			
		||||
  # strip whitespace
 | 
			
		||||
  $TLH =~ s/\s//g;
 | 
			
		||||
  # add trailing dots if none are present yet
 | 
			
		||||
  # (using negative look-behind assertions)
 | 
			
		||||
  $TLH =~ s/(?<!\.):/.:/g;
 | 
			
		||||
  $TLH =~ s/(?<!\.)$/./;
 | 
			
		||||
  # check for illegal characters
 | 
			
		||||
  &Bleat(2,'Config error - illegal characters in TLH definition!')
 | 
			
		||||
    if ($TLH !~ /^[a-zA-Z0-9:+.-]+$/);
 | 
			
		||||
  # escape dots
 | 
			
		||||
  $TLH =~ s/\./\\./g;
 | 
			
		||||
  if ($TLH =~ /:/) {
 | 
			
		||||
    # reformat $TLH from a:b to (a)|(b),
 | 
			
		||||
    # e.g. replace ':' by ')|('
 | 
			
		||||
    $TLH =~ s/:/)|(/g;
 | 
			
		||||
    $TLH = '(' . $TLH . ')';
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
### init database
 | 
			
		||||
my $DBHandle = InitDB(\%Conf,1);
 | 
			
		||||
my $DBRaw    = sprintf('%s.%s',$Conf{'DBDatabase'},$Conf{'DBTableRaw'});
 | 
			
		||||
| 
						 | 
				
			
			@ -127,6 +98,34 @@ foreach my $Month (&ListMonth($Period)) {
 | 
			
		|||
 | 
			
		||||
  ### GroupStats
 | 
			
		||||
  if ($OptStatsType eq 'all' or $OptStatsType eq 'groups') {
 | 
			
		||||
    ### reformat $Conf{'TLH'}
 | 
			
		||||
    my $TLH;
 | 
			
		||||
    if ($Conf{'TLH'}) {
 | 
			
		||||
      # $Conf{'TLH'} is parsed as an array by Config::Auto;
 | 
			
		||||
      # make a flat list again, separated by :
 | 
			
		||||
      if (ref($Conf{'TLH'}) eq 'ARRAY') {
 | 
			
		||||
        $TLH = join(':',@{$Conf{'TLH'}});
 | 
			
		||||
      } else {
 | 
			
		||||
        $TLH  = $Conf{'TLH'};
 | 
			
		||||
      }
 | 
			
		||||
      # strip whitespace
 | 
			
		||||
      $TLH =~ s/\s//g;
 | 
			
		||||
      # add trailing dots if none are present yet
 | 
			
		||||
      # (using negative look-behind assertions)
 | 
			
		||||
      $TLH =~ s/(?<!\.):/.:/g;
 | 
			
		||||
      $TLH =~ s/(?<!\.)$/./;
 | 
			
		||||
      # check for illegal characters
 | 
			
		||||
      &Bleat(2,'Config error - illegal characters in TLH definition!')
 | 
			
		||||
        if ($TLH !~ /^[a-zA-Z0-9:+.-]+$/);
 | 
			
		||||
      # escape dots
 | 
			
		||||
      $TLH =~ s/\./\\./g;
 | 
			
		||||
      if ($TLH =~ /:/) {
 | 
			
		||||
        # reformat $TLH from a:b to (a)|(b),
 | 
			
		||||
        # e.g. replace ':' by ')|('
 | 
			
		||||
        $TLH =~ s/:/)|(/g;
 | 
			
		||||
        $TLH = '(' . $TLH . ')';
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
    &GroupStats($DBHandle,$DBRaw,$DBGrps,$Month,$TLH,$OptCheckgroupsFile,$OptMID,$OptTest,$OptDebug);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
NewsStats 0.4.0 (unreleased)
 | 
			
		||||
 | 
			
		||||
  * Reformat $Conf{TLH} for GroupStats only.
 | 
			
		||||
 | 
			
		||||
NewsStats 0.3.0 (2025-05-18)
 | 
			
		||||
  * Extract GroupStats (in gatherstats) to subroutine.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue