Skip to content

Commit

Permalink
Merge branch 'deploy' into min-bins
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Nov 27, 2024
2 parents 04aa513 + d626792 commit 211620d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions backend/app/get_travel_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def get_travel_time(start_node, end_node, start_time, end_time, start_date, end_
SELECT 1 FROM ref.holiday WHERE ta.dt = holiday.dt
)'''

# if end_time is less than the start_time, then we wrap around midnight
ToD_and_or = 'AND' if end_time > start_time else 'OR'

query = f'''
SELECT
link_dir,
Expand All @@ -45,8 +48,10 @@ def get_travel_time(start_node, end_node, start_time, end_time, start_date, end_
FROM here.ta
WHERE
link_dir = ANY(%(link_dir_list)s)
AND tod >= %(start_time)s::time
AND tod < %(end_time)s::time
AND (
tod >= %(start_time)s::time
{ToD_and_or} tod < %(end_time)s::time
)
AND date_part('ISODOW', dt) = ANY(%(dow_list)s)
AND dt >= %(start_date)s::date
AND dt < %(end_date)s::date
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/timeRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class TimeRange extends Factor {
if(!(this.#startTime && this.#endTime)){
return false
}
return this.startHour < this.endHour
return this.startHour != this.endHour
}
get name(){
if(this.#startTime || this.#endTime){
Expand Down Expand Up @@ -68,7 +68,11 @@ export class TimeRange extends Factor {
}
get hoursInRange(){ // how many hours are in the timeRange?
if(! this.isComplete){ return undefined }
return this.endHour - this.startHour
if(this.endHour > this.startHour){
return this.endHour - this.startHour
} else {
return 24 - this.startHour + this.endHour
}
}
}

Expand Down

0 comments on commit 211620d

Please sign in to comment.