@@ -6,6 +6,7 @@ import {DEFAULT_PER_PAGE} from 'app/constants';
6
6
import { EventViewv1 } from 'app/types' ;
7
7
import { SavedQuery as LegacySavedQuery } from 'app/views/discover/types' ;
8
8
import { SavedQuery , NewQuery } from 'app/stores/discoverSavedQueriesStore' ;
9
+ import { getParams } from 'app/components/organizations/globalSelectionHeader/getParams' ;
9
10
10
11
import { AUTOLINK_FIELDS , SPECIAL_FIELDS , FIELD_FORMATTERS } from './data' ;
11
12
import {
@@ -350,6 +351,8 @@ class EventView {
350
351
}
351
352
352
353
static fromLocation ( location : Location ) : EventView {
354
+ const { start, end, statsPeriod} = getParams ( location . query ) ;
355
+
353
356
return new EventView ( {
354
357
id : decodeScalar ( location . query . id ) ,
355
358
name : decodeScalar ( location . query . name ) ,
@@ -358,9 +361,9 @@ class EventView {
358
361
tags : collectQueryStringByKey ( location . query , 'tag' ) ,
359
362
query : decodeQuery ( location ) || '' ,
360
363
project : decodeProjects ( location ) ,
361
- start : decodeScalar ( location . query . start ) ,
362
- end : decodeScalar ( location . query . end ) ,
363
- statsPeriod : decodeScalar ( location . query . statsPeriod ) ,
364
+ start : decodeScalar ( start ) ,
365
+ end : decodeScalar ( end ) ,
366
+ statsPeriod : decodeScalar ( statsPeriod ) ,
364
367
environment : collectQueryStringByKey ( location . query , 'environment' ) ,
365
368
} ) ;
366
369
}
@@ -402,22 +405,30 @@ class EventView {
402
405
} ) ;
403
406
}
404
407
408
+ // normalize datetime selection
409
+
410
+ const { start, end, statsPeriod} = getParams ( {
411
+ start : saved . start ,
412
+ end : saved . end ,
413
+ statsPeriod : saved . range ,
414
+ } ) ;
415
+
405
416
return new EventView ( {
406
417
fields,
407
418
id : saved . id ,
408
419
name : saved . name ,
409
420
query : queryStringFromSavedQuery ( saved ) ,
410
421
project : saved . projects ,
411
- start : saved . start ,
412
- end : saved . end ,
422
+ start : decodeScalar ( start ) ,
423
+ end : decodeScalar ( end ) ,
424
+ statsPeriod : decodeScalar ( statsPeriod ) ,
413
425
sorts : fromSorts ( saved . orderby ) ,
414
426
tags : collectQueryStringByKey (
415
427
{
416
428
tags : ( saved as SavedQuery ) . tags as string [ ] ,
417
429
} ,
418
430
'tags'
419
431
) ,
420
- statsPeriod : saved . range ,
421
432
environment : collectQueryStringByKey (
422
433
{
423
434
environment : ( saved as SavedQuery ) . environment as string [ ] ,
@@ -845,17 +856,31 @@ class EventView {
845
856
846
857
const picked = pickRelevantLocationQueryStrings ( location ) ;
847
858
859
+ // normalize datetime selection
860
+
861
+ const normalizedTimeWindowParams = getParams ( {
862
+ start : this . start ,
863
+ end : this . end ,
864
+ period : decodeScalar ( query . period ) ,
865
+ statsPeriod : this . statsPeriod ,
866
+ utc : decodeScalar ( query . utc ) ,
867
+ } ) ;
868
+
848
869
const sort = this . sorts . length > 0 ? encodeSort ( this . sorts [ 0 ] ) : undefined ;
849
870
const fields = this . getFields ( ) ;
850
871
851
872
// generate event query
852
873
853
- const eventQuery : EventQuery & LocationQuery = Object . assign ( picked , {
854
- field : [ ...new Set ( fields ) ] ,
855
- sort,
856
- per_page : DEFAULT_PER_PAGE ,
857
- query : this . getQuery ( query . query ) ,
858
- } ) ;
874
+ const eventQuery : EventQuery & LocationQuery = Object . assign (
875
+ picked ,
876
+ normalizedTimeWindowParams ,
877
+ {
878
+ field : [ ...new Set ( fields ) ] ,
879
+ sort,
880
+ per_page : DEFAULT_PER_PAGE ,
881
+ query : this . getQuery ( query . query ) ,
882
+ }
883
+ ) ;
859
884
860
885
if ( ! eventQuery . sort ) {
861
886
delete eventQuery . sort ;
0 commit comments