Skip to content

Commit

Permalink
cache results
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Sep 15, 2023
1 parent db315b5 commit b1c5f15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/src/spatialData.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export class SpatialData {
return [...this.#queries.values()]
}
fetchAllResults(){
return Promise.all(this.travelTimeQueries.map(TTQ=>TTQ.fetchData()))
return Promise.all(
this.travelTimeQueries
.filter( TTQ => ! TTQ.hasData )
.map( TTQ => TTQ.fetchData() )
)
}
}
3 changes: 3 additions & 0 deletions frontend/src/travelTimeQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class TravelTimeQuery {
this.#travelTime = data.travel_time
} )
}
get hasData(){
return Boolean(this.#travelTime)
}
resultsRecord(type='json'){
const record = {
URI: this.URI,
Expand Down

0 comments on commit b1c5f15

Please sign in to comment.