events.pm: add query param last_days
This commit is contained in:
@@ -843,15 +843,17 @@ sub getDateQueryConditions ($$$) {
|
|||||||
push @$bind_values, $weekday;
|
push @$bind_values, $weekday;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $params->{archive} eq 'past' ) {
|
if ( $params->{last_days} ) {
|
||||||
|
my $d = int $params->{last_days};
|
||||||
|
push @$date_conds, qq{ ( end between date_sub(now(),INTERVAL $d DAY) and now() ) };
|
||||||
|
} elsif ( $params->{archive} eq 'past' ) {
|
||||||
my $date = time::get_event_date($config);
|
my $date = time::get_event_date($config);
|
||||||
if ( $date ne '' ) {
|
if ( $date ne '' ) {
|
||||||
push @$date_conds, ' ( start < ? ) ';
|
push @$date_conds, ' ( start < ? ) ';
|
||||||
push @$bind_values, $date;
|
push @$bind_values, $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} elsif ( $params->{archive} eq 'future' ) {
|
||||||
if ( $params->{archive} eq 'future' ) {
|
|
||||||
my $date = time::get_event_date($config);
|
my $date = time::get_event_date($config);
|
||||||
if ( $date ne '' ) {
|
if ( $date ne '' ) {
|
||||||
push @$date_conds, ' ( end >= ? ) ';
|
push @$date_conds, ' ( end >= ? ) ';
|
||||||
@@ -1681,6 +1683,8 @@ sub check_params ($$) {
|
|||||||
$archive = 'future' if ( $params->{archive} eq 'coming' );
|
$archive = 'future' if ( $params->{archive} eq 'coming' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $last_days = defined $params->{last_days} ? int($params->{last_days}) : 0;
|
||||||
|
|
||||||
my $disable_event_sync = '';
|
my $disable_event_sync = '';
|
||||||
if ( ( defined $params->{disable_event_sync} )
|
if ( ( defined $params->{disable_event_sync} )
|
||||||
&& ( $params->{disable_event_sync} =~ /([01])/ ) )
|
&& ( $params->{disable_event_sync} =~ /([01])/ ) )
|
||||||
@@ -1797,6 +1801,7 @@ sub check_params ($$) {
|
|||||||
search => $search,
|
search => $search,
|
||||||
debug => $debug,
|
debug => $debug,
|
||||||
archive => $archive,
|
archive => $archive,
|
||||||
|
last_days => $last_days,
|
||||||
order => $order,
|
order => $order,
|
||||||
project => $project,
|
project => $project,
|
||||||
default_project => $default_project,
|
default_project => $default_project,
|
||||||
@@ -1818,7 +1823,6 @@ sub check_params ($$) {
|
|||||||
set_no_listen_keys => $set_no_listen_keys,
|
set_no_listen_keys => $set_no_listen_keys,
|
||||||
ro => ($params->{ro}//'') ? 1 : 0
|
ro => ($params->{ro}//'') ? 1 : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
return $checked;
|
return $checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user