diff --git a/backend/app/get_travel_time.py b/backend/app/get_travel_time.py index 245159e..c835d24 100644 --- a/backend/app/get_travel_time.py +++ b/backend/app/get_travel_time.py @@ -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 = [] @@ -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 } \ No newline at end of file diff --git a/frontend/src/travelTimeQuery.js b/frontend/src/travelTimeQuery.js index 54e0a28..5a3269b 100644 --- a/frontend/src/travelTimeQuery.js +++ b/frontend/src/travelTimeQuery.js @@ -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) @@ -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)