Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
7585e73d
Commit
7585e73d
authored
Jul 24, 2013
by
Byron Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 533878: Allow relative date searches involving date/time custom fields
r=LpSolit, a=sgreen
parent
3f1ae227
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
8 deletions
+27
-8
Search.pm
Bugzilla/Search.pm
+26
-8
011pod.t
t/011pod.t
+1
-0
No files found.
Bugzilla/Search.pm
View file @
7585e73d
...
@@ -322,7 +322,9 @@ use constant OPERATOR_FIELD_OVERRIDE => {
...
@@ -322,7 +322,9 @@ use constant OPERATOR_FIELD_OVERRIDE => {
# These are fields where special action is taken depending on the
# These are fields where special action is taken depending on the
# *value* passed in to the chart, sometimes.
# *value* passed in to the chart, sometimes.
use
constant
SPECIAL_PARSING
=>
{
# This is a sub because custom fields are dynamic
sub
SPECIAL_PARSING
{
my
$map
=
{
# Pronoun Fields (Ones that can accept %user%, etc.)
# Pronoun Fields (Ones that can accept %user%, etc.)
assigned_to
=>
\&
_contact_pronoun
,
assigned_to
=>
\&
_contact_pronoun
,
cc
=>
\&
_contact_pronoun
,
cc
=>
\&
_contact_pronoun
,
...
@@ -333,9 +335,18 @@ use constant SPECIAL_PARSING => {
...
@@ -333,9 +335,18 @@ use constant SPECIAL_PARSING => {
'requestees.login_name'
=>
\&
_contact_pronoun
,
'requestees.login_name'
=>
\&
_contact_pronoun
,
# Date Fields that accept the 1d, 1w, 1m, 1y, etc. format.
# Date Fields that accept the 1d, 1w, 1m, 1y, etc. format.
creation_ts
=>
\&
_timestamp_translate
,
creation_ts
=>
\&
_datetime_translate
,
deadline
=>
\&
_timestamp_translate
,
deadline
=>
\&
_date_translate
,
delta_ts
=>
\&
_timestamp_translate
,
delta_ts
=>
\&
_datetime_translate
,
};
foreach
my
$field
(
Bugzilla
->
active_custom_fields
)
{
if
(
$field
->
type
==
FIELD_TYPE_DATETIME
)
{
$map
->
{
$field
->
name
}
=
\&
_datetime_translate
;
}
elsif
(
$field
->
type
==
FIELD_TYPE_DATE
)
{
$map
->
{
$field
->
name
}
=
\&
_date_translate
;
}
}
return
$map
;
};
};
# Information about fields that represent "users", used by _user_nonchanged.
# Information about fields that represent "users", used by _user_nonchanged.
...
@@ -2083,22 +2094,29 @@ sub _word_terms {
...
@@ -2083,22 +2094,29 @@ sub _word_terms {
#####################################
#####################################
sub
_timestamp_translate
{
sub
_timestamp_translate
{
my
(
$self
,
$args
)
=
@_
;
my
(
$self
,
$
ignore_time
,
$
args
)
=
@_
;
my
$value
=
$args
->
{
value
};
my
$value
=
$args
->
{
value
};
my
$dbh
=
Bugzilla
->
dbh
;
my
$dbh
=
Bugzilla
->
dbh
;
return
if
$value
!~
/^(?:[\+\-]?\d+[hdwmy]s?|now)$/i
;
return
if
$value
!~
/^(?:[\+\-]?\d+[hdwmy]s?|now)$/i
;
# By default, the time is appended to the date, which we don't want
# for deadlines.
$value
=
SqlifyDate
(
$value
);
$value
=
SqlifyDate
(
$value
);
if
(
$args
->
{
field
}
eq
'deadline'
)
{
# By default, the time is appended to the date, which we don't always want.
if
(
$ignore_time
)
{
(
$value
)
=
split
(
/\s/
,
$value
);
(
$value
)
=
split
(
/\s/
,
$value
);
}
}
$args
->
{
value
}
=
$value
;
$args
->
{
value
}
=
$value
;
$args
->
{
quoted
}
=
$dbh
->
quote
(
$value
);
$args
->
{
quoted
}
=
$dbh
->
quote
(
$value
);
}
}
sub
_datetime_translate
{
return
shift
->
_timestamp_translate
(
0
,
@_
);
}
sub
_date_translate
{
return
shift
->
_timestamp_translate
(
1
,
@_
);
}
sub
SqlifyDate
{
sub
SqlifyDate
{
my
(
$str
)
=
@_
;
my
(
$str
)
=
@_
;
my
$fmt
=
"%Y-%m-%d %H:%M:%S"
;
my
$fmt
=
"%Y-%m-%d %H:%M:%S"
;
...
...
t/011pod.t
View file @
7585e73d
...
@@ -31,6 +31,7 @@ use constant SUB_WHITELIST => (
...
@@ -31,6 +31,7 @@ use constant SUB_WHITELIST => (
'Bugzilla::Flag' => qr/^(?:(force_)?retarget|force_cleanup)$/,
'Bugzilla::Flag' => qr/^(?:(force_)?retarget|force_cleanup)$/,
'Bugzilla::FlagType' => qr/^sqlify_criteria$/,
'Bugzilla::FlagType' => qr/^sqlify_criteria$/,
'Bugzilla::JobQueue' => qr/(?:^work_once|subprocess_worker)$/,
'Bugzilla::JobQueue' => qr/(?:^work_once|subprocess_worker)$/,
'Bugzilla::Search' => qr/^SPECIAL_PARSING$/,
);
);
# These modules do not need to be documented, generally because they
# These modules do not need to be documented, generally because they
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment