Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to *current* map version #180

Draft
wants to merge 2 commits into
base: deploy
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/app/get_travel_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from app.db import getConnection
from app.get_here_links import get_here_links
from app.selectMapVersion import selectMapVersion
from app.hereMapVersion import hereMapVersion
from traveltimetools.utils import timeFormats
import numpy
import math
Expand Down
37 changes: 37 additions & 0 deletions backend/app/hereMapVersion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from app.db import getConnection

# Selects Here map version to use based on dates in the provided query.
# however the query also has nodes which may or may not be version-specific

rangeQuery = """
WITH coverage AS (
SELECT
street_version,
valid_range * daterange(%(start_date)s, %(end_date)s,'[)') AS overlap
FROM here.street_valid_range
)

SELECT street_version
FROM coverage
WHERE UPPER(overlap) - LOWER(overlap) IS NOT NULL
ORDER BY UPPER(overlap) - LOWER(overlap) DESC NULLS LAST;
"""

nowQuery = """
SELECT street_version
FROM here.street_valid_range
WHERE valid_range @> NOW()::date;
"""

def hereMapVersion(start_date=None, end_date=None):
connection = getConnection()
with connection:
with connection.cursor() as cursor:
# a daterange has been provided
cursor.execute(
rangeQuery if start_date and end_date else nowQuery,
{'start_date':start_date,'end_date':end_date}
)
(map_version) = cursor.fetchone()
connection.close()
return map_version
28 changes: 0 additions & 28 deletions backend/app/selectMapVersion.py

This file was deleted.

Loading