Skip to content

fix(discover2): Various fixes #15315

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

Merged
merged 20 commits into from
Oct 31, 2019
Merged

fix(discover2): Various fixes #15315

merged 20 commits into from
Oct 31, 2019

Conversation

dashed
Copy link
Member

@dashed dashed commented Oct 29, 2019

Some various fixes:

  • The table metadata could be null, so we mark it as potentially null, and add guards as necessary.

  • If either start/end query string is provided, it may be missing end/start respectively, and easily break discover2; especially when URLs are meant to be shareable. This can occur in copy/paste mishaps. As a fallback, the statsPeriod will be coerced to a value of 14d.

  • Parse and validate statsPeriod, start, and end query strings at the global selection header store.

  • normalize datetime strings from start and end to be YYYY-MM-DDTHH:mm:ss.SSS

  • Properly parse datetime strings in EventView.fromLocation() and EventView. fromSavedQuery()

TODO

  • consolidate getParams to the global selection header folder.

@dashed dashed self-assigned this Oct 29, 2019
Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems valid to me

@dashed dashed force-pushed the discover2-fixes-oct-29-2019 branch from 54cfce6 to de14b90 Compare October 29, 2019 20:13
@dashed dashed requested a review from markstory October 29, 2019 23:07
@dashed dashed requested review from billyvg and markstory October 30, 2019 03:53

import {URL_PARAM} from 'app/constants/globalSelectionHeader';

// Parses URL query parameters for values relevant to global selection header
export function getStateFromQuery(query) {
let start = query[URL_PARAM.START] !== 'null' && query[URL_PARAM.START];
let end = query[URL_PARAM.END] !== 'null' && query[URL_PARAM.END];
const parsedParams = getParams(query);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing some issues stemming from the global selection header propagating down to discover2.

Invalid datetime selections can easily throw an error and break the app with no actual recovery flow.

I feel it's better to parse and validate the datetime selection early here; rather than doing it at the API payload generation everywhere.

@@ -2,17 +2,20 @@ import {pick, pickBy, identity} from 'lodash';

import {defined} from 'app/utils';
import {getUtcToLocalDateObject} from 'app/utils/dates';
import {getParams} from 'app/views/events/utils/getParams';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this function be moved to live with the other global selection functions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can move getParams to this file.


const getDateTimeString = (
maybe: string | string[] | undefined | null
): string | undefined => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and a few of the other parsers in this file have similar function bodies with only the validator/parsing operation being different. Could we extract that duplication?

@dashed dashed force-pushed the discover2-fixes-oct-29-2019 branch 2 times, most recently from 21bcc4b to 8af00b1 Compare October 30, 2019 23:24
@dashed dashed force-pushed the discover2-fixes-oct-29-2019 branch from 64b3447 to 954c129 Compare October 31, 2019 15:36
@dashed dashed merged commit 6c69583 into master Oct 31, 2019
@dashed dashed deleted the discover2-fixes-oct-29-2019 branch October 31, 2019 16:38
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants