Skip to content

Commit

Permalink
feat: better search effect
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercchase committed Jul 17, 2024
1 parent 0d8707c commit 0ebefb5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
4 changes: 3 additions & 1 deletion src/app/services/search-params.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ export class SearchParamsService {

private timeseriesParams$ = combineLatest([
this.searchPolygon$,
this.burstParams$
this.burstParams$,
this.maxResults$,
this.selectedDataset$,
]).pipe(
map((params: any[]) => params
.reduce(
Expand Down
55 changes: 33 additions & 22 deletions src/app/store/search/search.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class SearchEffects {
private sarviewsService: services.SarviewsEventsService,
private http: HttpClient,
private notificationService: services.NotificationService,
private netCdfService: services.NetcdfServiceService
) { }

public clearMapInteractionModeOnSearch = createEffect(() => this.actions$.pipe(
Expand Down Expand Up @@ -573,28 +574,38 @@ export class SearchEffects {
}

private timeseriesQuery$() {
return of(new TimeseriesSearchResponse({}))
// this.netCdfService.getTimeSeries({'lon': 1, 'lat':1}).pipe(
// map(_stuff => {
// console.log(_stuff)
// return of(new TimeseriesSearchResponse({}))
// })
// )
// return combineLatest(
// this.asfApiQuery$,
// this.searchParams$.getParams.pipe(
// map(params => {
// this.netCdfService.getTimeSeries(params)
// })
// )
// ).pipe(
// switchMap(([_project, _test]) => {
// console.log(_project)
// return of(new TimeseriesSearchResponse({}))
// })
// results => {
// )
// }
return this.searchParams$.getParams.pipe(
switchMap(
(params) =>
this.asfApiService.query<any[]>(params).pipe(
withLatestFrom(combineLatest([
this.store$.select(getSearchType),
this.store$.select(getIsCanceled),
this.netCdfService.getTimeSeries({'lon': 1, 'lat':1}) // eventually grab params for points in this part
]
)),
map(([response, [searchType, isCanceled, timseries]]) => {
const files = this.productService.fromResponse(response)
return !isCanceled ?
new TimeseriesSearchResponse({
files,
totalCount: files.length,
searchType,
timseries
}) :
new SearchCanceled()
}
),
catchError(
(err: HttpErrorResponse) => {
if (err.status !== 400) {
return of(new SearchError(`Unknown Error`));
}
return EMPTY;
}
),
))
);
}

private hyp3JobToProducts(jobs, products) {
Expand Down

0 comments on commit 0ebefb5

Please sign in to comment.