-
Notifications
You must be signed in to change notification settings - Fork 105
Feature/p1 release #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/p1 release #133
Changes from 20 commits
c2a5647
53f2057
bf6daf6
493a334
4cf83bb
a5d3b3b
2e6a1e8
4cb8b73
99fd853
5c2eb10
f03d6bd
2809609
460411a
5655570
482129a
5088c9e
c2f1681
2f3370d
c43aacd
5e8e377
b94d2cd
3bee70a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,45 @@ | |
| * GitHub history for details. | ||
| */ | ||
|
|
||
| import { PPL_INDEX_REGEX } from "../constants/shared"; | ||
| import { isEmpty } from 'lodash'; | ||
| import datemath from '@elastic/datemath'; | ||
| import { DATE_PICKER_FORMAT } from '../../common/constants/explorer'; | ||
| import { | ||
| PPL_INDEX_REGEX, | ||
| PPL_INDEX_INSERT_POINT_REGEX | ||
| } from '../../common/constants/shared'; | ||
|
|
||
| export const getIndexPatternFromRawQuery = (query: string) : string => { | ||
| const matches = query.match(PPL_INDEX_REGEX); | ||
| if (matches) { | ||
| return matches[2]; | ||
| } | ||
| return ''; | ||
| }; | ||
|
|
||
| export const insertDateRangeToQuery = ({ | ||
| rawQuery, | ||
| startTime, | ||
| endTime, | ||
| timeField = 'utc_time', | ||
| }: { | ||
| rawQuery: string; | ||
| startTime: string; | ||
| endTime: string; | ||
| timeField?: string; | ||
| }) => { | ||
|
|
||
| let finalQuery = ''; | ||
|
|
||
| if (isEmpty(rawQuery)) return finalQuery; | ||
|
|
||
| // convert to moment | ||
| const start = datemath.parse(startTime)?.format(DATE_PICKER_FORMAT); | ||
| const end = datemath.parse(endTime)?.format(DATE_PICKER_FORMAT); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you select something like
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, on handler side, I added the code to check and change the end to be 'now' if start and end are the same.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mengweieric i think instead of changing it to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, this makes sense, I'll change it. |
||
| const tokens = rawQuery.match(PPL_INDEX_INSERT_POINT_REGEX); | ||
|
|
||
| if (isEmpty(tokens)) return finalQuery; | ||
| finalQuery = `search ${tokens![1]}=${tokens![2]} | where ${timeField} >= timestamp('${start}') and ${timeField} <= timestamp('${end}')${tokens![3]}`; | ||
|
|
||
| return finalQuery; | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.