Skip to content

Commit

Permalink
let the backend return what it can
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed May 22, 2024
1 parent 9fba617 commit b9bde2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions backend/app/get_travel_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ def get_travel_time(start_node, end_node, start_time, end_time, start_date, end_
tt_hourly = [ tt for (dt,tt) in sample ]

if len(sample) < 1:
return {'error': 'not enough data'}
# no ravel times or related info to return here
return {
'results': {
'confidence': { 'sample': 0 },
'corridor':{ 'links': links },
'query_params': query_params
}
}

# bootstrap for synthetic sample distribution
sample_distribution = []
Expand Down Expand Up @@ -108,8 +115,6 @@ def get_travel_time(start_node, end_node, start_time, end_time, start_date, end_
}
}
},
'corridor':{
'links': links
},
'corridor':{ 'links': links },
'query_params': query_params
}
4 changes: 2 additions & 2 deletions frontend/src/travelTimeQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TravelTimeQuery {
}
return fetch(this.URI)
.then( response => response.json() )
.then( data => this.#results = data?.results )
.then( data => this.#results = data.results )
}
get hasData(){
return Boolean(this.#results)
Expand All @@ -61,7 +61,7 @@ export class TravelTimeQuery {
record.set('daysOfWeek', this.days.name)
record.set('holidaysIncluded', this.#holidayOption.holidaysIncluded)
record.set('hoursInRange', this.hoursInRange)
record.set('sample', this.#results?.confidence?.sample ?? 0)
record.set('sample', this.#results.confidence?.sample)
record.set('mean_travel_time_minutes', this.#results?.travel_time?.minutes)
record.set('mean_travel_time_seconds', this.#results?.travel_time?.seconds)
record.set('moe_lower_p95', this.#results?.confidence?.intervals?.['p=0.95']?.lower?.seconds)
Expand Down

0 comments on commit b9bde2d

Please sign in to comment.