@@ -531,11 +531,28 @@ export class RequestApi extends Http {
531531 mode : string = 'forecast' ,
532532 ) => {
533533 const ret : Promise < AxiosResponse < any , any > > [ ] = [ ] ;
534- for ( let id of series ) {
535- ret . push ( this . getTimeserieV2 ( id , lat , lng , withStation ) ) ;
536- if ( withStation ) {
537- withStation = false ;
534+ if ( mode === 'forecast' ) {
535+ for ( let id of series ) {
536+ ret . push (
537+ this . getTimeserieV2 (
538+ id ,
539+ lat ,
540+ lng ,
541+ withStation ,
542+ true ,
543+ true ,
544+ true ,
545+ mode ,
546+ ) ,
547+ ) ;
548+ if ( withStation ) {
549+ withStation = false ;
550+ }
538551 }
552+ } else {
553+ ret . push (
554+ this . getTimeserieV2 ( series [ 0 ] , lat , lng , false , true , true , true , mode ) ,
555+ ) ;
539556 }
540557 return Promise . all ( ret ) . then ( x => {
541558 return this . merge . apply ( this , x ) ;
@@ -554,6 +571,24 @@ export class RequestApi extends Http {
554571 { } ,
555572 ) ;
556573
574+ public updateCache = ( ) => {
575+ this . instance . get ( `${ BACKEND_API_URL } /base` ) . then ( ( x : any ) => {
576+ const curr = localStorage . getItem ( 'git_commit' ) ;
577+ console . log ( 'current_version' , curr ) ;
578+ if ( curr ) {
579+ if ( curr !== x . git_commit ) {
580+ localStorage . clear ( ) ;
581+ console . log ( 'localStorage cleaered' ) ;
582+ }
583+ localStorage . setItem ( 'git_commit' , x . git_commit ) ;
584+ } else {
585+ localStorage . clear ( ) ;
586+ console . log ( 'localStorage cleaered' ) ;
587+ localStorage . setItem ( 'git_commit' , x . git_commit ) ;
588+ }
589+ } ) ;
590+ } ;
591+
557592 public getTimeserieV2 = (
558593 serie : string ,
559594 lat : number ,
@@ -564,6 +599,7 @@ export class RequestApi extends Http {
564599 uncertainty : boolean = true ,
565600 mode : string = 'forecast' ,
566601 ) => {
602+ serie . indexOf ( 'forecast' ) >= 0 ? ( mode = 'forecast' ) : ( mode = 'past' ) ;
567603 const ep =
568604 mode === 'forecast' ? 'forecast-time-series' : 'historical-time-series' ;
569605 let url = `${ BACKEND_API_URL } /coverages/${ ep } /${ serie } ?coords=POINT(${ lng . toFixed (
@@ -572,8 +608,13 @@ export class RequestApi extends Http {
572608 4 ,
573609 ) } )&datetime=..%2F..&include_coverage_data=true&coverage_data_smoothing=NO_SMOOTHING`;
574610 if ( smoothing ) {
575- url +=
576- '&coverage_data_smoothing=MOVING_AVERAGE_11_YEARS&coverage_data_smoothing=LOESS_SMOOTHING' ;
611+ if ( mode === 'forecast' ) {
612+ url +=
613+ '&coverage_data_smoothing=MOVING_AVERAGE_11_YEARS&coverage_data_smoothing=LOESS_SMOOTHING' ;
614+ } else {
615+ url +=
616+ '&mann_kendall_datetime=..%2F..&include_moving_average_series=true&include_decade_aggregation_series=true&include_loess_series=true' ;
617+ }
577618 }
578619 if ( uncertainty ) {
579620 url += '&include_coverage_uncertainty=true' ;
@@ -590,6 +631,8 @@ export class RequestApi extends Http {
590631 } else {
591632 url += '&include_observation_data=false' ;
592633 }
634+ if ( mode !== 'forecast' ) {
635+ }
593636
594637 return this . instance . get < any > ( url ) . then ( ( x : any ) => {
595638 x . series . map ( a => {
@@ -688,7 +731,7 @@ export class RequestApi extends Http {
688731 } ;
689732
690733 public getAttributes = (
691- data : string = 'future ' ,
734+ data : string = 'forecast ' ,
692735 mode : string = 'advanced' ,
693736 force : boolean = false ,
694737 ) => {
@@ -703,7 +746,7 @@ export class RequestApi extends Http {
703746 return d . items ;
704747 } ) ;
705748 reqs . push ( ret ) ;
706- if ( data === 'future ' ) {
749+ if ( data === 'forecast ' ) {
707750 const cret = this . instance . get < any > (
708751 `${ BACKEND_API_URL } /coverages/forecast-variable-combinations?navigation_section=${ mode } ` ,
709752 ) ;
0 commit comments