spacing and quotes

This commit is contained in:
Isaac Connor 2019-06-11 13:32:15 -04:00
parent acb95709e6
commit 1928d1153f
1 changed files with 44 additions and 47 deletions

View File

@ -238,8 +238,7 @@ sub Sql {
} else {
$value = DateTimeToSQL($temp_value);
if ( !$value ) {
Error( "Error parsing date/time '$temp_value', "
."skipping filter '$self->{Name}'\n" );
Error("Error parsing date/time '$temp_value', skipping filter '$self->{Name}'");
return;
}
$value = "'$value'";
@ -250,8 +249,7 @@ sub Sql {
} else {
$value = DateTimeToSQL($temp_value);
if ( !$value ) {
Error( "Error parsing date/time '$temp_value', "
."skipping filter '$self->{Name}'\n" );
Error("Error parsing date/time '$temp_value', skipping filter '$self->{Name}'");
return;
}
$value = "to_days( '$value' )";
@ -262,8 +260,7 @@ sub Sql {
} else {
$value = DateTimeToSQL($temp_value);
if ( !$value ) {
Error( "Error parsing date/time '$temp_value', "
."skipping filter '$self->{Name}'\n" );
Error("Error parsing date/time '$temp_value', skipping filter '$self->{Name}'");
return;
}
$value = "extract( hour_second from '$value' )";
@ -271,7 +268,7 @@ sub Sql {
} else {
$value = $temp_value;
}
push( @value_list, $value );
push @value_list, $value;
} # end foreach temp_value
} # end if has an attr
if ( $term->{op} ) {
@ -290,15 +287,15 @@ sub Sql {
} elsif ( $term->{op} eq 'IS NOT' ) {
$self->{Sql} .= " IS NOT $value";
} elsif ( $term->{op} eq '=[]' ) {
$self->{Sql} .= " in (".join( ",", @value_list ).")";
$self->{Sql} .= ' IN ('.join(',', @value_list).')';
} elsif ( $term->{op} eq '!~' ) {
$self->{Sql} .= " not in (".join( ",", @value_list ).")";
$self->{Sql} .= ' NOT IN ('.join(',', @value_list).')';
} else {
$self->{Sql} .= ' '.$term->{op}." $value";
$self->{Sql} .= ' '.$term->{op}.' '.$value;
}
} # end if has an operator
if ( exists($term->{cbr}) ) {
$self->{Sql} .= ' '.str_repeat( ")", $term->{cbr} )." ";
$self->{Sql} .= ' '.str_repeat(')', $term->{cbr}).' ';
}
} # end foreach term
} # end if terms
@ -320,22 +317,22 @@ sub Sql {
# Don't do this, it prevents re-generation and concatenation.
# If the file already exists, then the video won't be re-recreated
if ( $self->{AutoVideo} ) {
push @auto_terms, "E.Videoed = 0";
push @auto_terms, 'E.Videoed = 0';
}
if ( $self->{AutoUpload} ) {
push @auto_terms, "E.Uploaded = 0";
push @auto_terms, 'E.Uploaded = 0';
}
if ( $self->{AutoEmail} ) {
push @auto_terms, "E.Emailed = 0";
push @auto_terms, 'E.Emailed = 0';
}
if ( $self->{AutoMessage} ) {
push @auto_terms, "E.Messaged = 0";
push @auto_terms, 'E.Messaged = 0';
}
if ( $self->{AutoExecute} ) {
push @auto_terms, "E.Executed = 0";
push @auto_terms, 'E.Executed = 0';
}
if ( @auto_terms ) {
$sql .= " and ( ".join( ' or ', @auto_terms )." )";
$sql .= ' AND ( '.join(' or ', @auto_terms).' )';
}
if ( !$filter_expr->{sort_field} ) {
$filter_expr->{sort_field} = 'StartTime';
@ -369,10 +366,10 @@ sub Sql {
} else {
$sort_column = 'E.StartTime';
}
my $sort_order = $filter_expr->{sort_asc}?'asc':'desc';
$sql .= ' order by '.$sort_column." ".$sort_order;
my $sort_order = $filter_expr->{sort_asc} ? 'ASC' : 'DESC';
$sql .= ' ORDER BY '.$sort_column." ".$sort_order;
if ( $filter_expr->{limit} ) {
$sql .= " limit 0,".$filter_expr->{limit};
$sql .= ' LIMIT 0,'.$filter_expr->{limit};
}
$self->{Sql} = $sql;
} # end if has Sql
@ -386,7 +383,7 @@ sub getDiskPercent {
if ( $df =~ /\s(\d+)%/ms ) {
$space = $1;
}
return( $space );
return $space;
}
sub getDiskBlocks {
@ -396,7 +393,7 @@ sub getDiskBlocks {
if ( $df =~ /\s(\d+)\s+\d+\s+\d+%/ms ) {
$space = $1;
}
return( $space );
return $space;
}
sub getLoad {
@ -407,7 +404,7 @@ sub getLoad {
$load = $1;
Info("Load: $load");
}
return( $load );
return $load;
}
#
@ -415,7 +412,7 @@ sub getLoad {
#
sub strtotime {
my $dt_str = shift;
return( Date::Manip::UnixDate( $dt_str, '%s' ) );
return Date::Manip::UnixDate($dt_str, '%s');
}
#
@ -424,7 +421,7 @@ sub strtotime {
sub str_repeat {
my $string = shift;
my $count = shift;
return( ${string}x${count} );
return ${string}x${count};
}
# Formats a date into MySQL format
@ -432,10 +429,10 @@ sub DateTimeToSQL {
my $dt_str = shift;
my $dt_val = strtotime($dt_str);
if ( !$dt_val ) {
Error( "Unable to parse date string '$dt_str'\n" );
return( undef );
Error("Unable to parse date string '$dt_str'");
return undef;
}
return( POSIX::strftime( "%Y-%m-%d %H:%M:%S", localtime( $dt_val ) ) );
return POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime($dt_val));
}
1;