-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(query-builder): Add support for duration filters (#74447)
Adds support for duration filters, which don't exist in issues search but can in other contexts. You can test it on the stories page, where I've added `measurements.lcp` as an option.
- Loading branch information
Showing
8 changed files
with
232 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
static/app/components/searchQueryBuilder/tokens/filter/parsers/duration/grammar.pegjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
value = duration_format | ||
|
||
duration_format | ||
= value:numeric | ||
unit:duration_unit? { | ||
return {value, unit} | ||
} | ||
|
||
duration_unit = "ms"/"s"/"min"/"m"/"hr"/"h"/"day"/"d"/"wk"/"w" | ||
numeric = [0-9]+ ("." [0-9]*)? { return text(); } |
21 changes: 21 additions & 0 deletions
21
static/app/components/searchQueryBuilder/tokens/filter/parsers/duration/parser.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import grammar from './grammar.pegjs'; | ||
|
||
type DurationTokenValue = { | ||
value: string; | ||
unit?: string; | ||
}; | ||
|
||
/** | ||
* This parser is specifically meant for parsing the value of a duartion filter. | ||
* This should mostly mirror the grammar used for search syntax, but is a little | ||
* more lenient. This parser still returns a valid result if the duration does | ||
* not contain a unit which can be used to help create a valid duration or show | ||
* search suggestions. | ||
*/ | ||
export function parseFilterValueDuration(query: string): DurationTokenValue | null { | ||
try { | ||
return grammar.parse(query); | ||
} catch (e) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters