Skip to content

Commit

Permalink
Merge pull request #314 from freezingsaddles/upgrade-database-libraries
Browse files Browse the repository at this point in the history
upgrade database libraries
  • Loading branch information
obscurerichard authored Dec 8, 2024
2 parents f6adf3b + 70d19c2 commit a4802f7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 22 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN pip3 install -r /tmp/requirements.txt
ADD . /app
RUN mkdir -p /data
COPY leaderboards /data/leaderboards
COPY alembic.ini /app
WORKDIR /app
RUN pip3 install .
ENV LEADERBOARDS_DIR=/data/leaderboards
Expand Down
5 changes: 3 additions & 2 deletions alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[alembic]
# path to migration scripts
script_location = alembic
script_location = freezing.model:migrations

# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
Expand All @@ -15,7 +15,8 @@ script_location = alembic
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# This is read from Flask config instead
# This is read from Flask config instead,
# or set the SQLALCHEMY_URL environment variable
# sqlalchemy.url = driver://user:pass@localhost/dbname


Expand Down
10 changes: 5 additions & 5 deletions freezing/web/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
RideTrack,
Team,
)
from geoalchemy import WKTSpatialElement
from geoalchemy2 import WKTElement
from instagram import InstagramAPIError, InstagramClientError
from requests.exceptions import HTTPError
from sqlalchemy import and_
Expand Down Expand Up @@ -343,7 +343,7 @@ def write_ride(activity):
"""

if activity.start_latlng:
start_geo = WKTSpatialElement(
start_geo = WKTElement(
"POINT({lon} {lat})".format(
lat=activity.start_latlng.lat, lon=activity.start_latlng.lon
)
Expand All @@ -352,7 +352,7 @@ def write_ride(activity):
start_geo = None

if activity.end_latlng:
end_geo = WKTSpatialElement(
end_geo = WKTElement(
"POINT({lon} {lat})".format(
lat=activity.end_latlng.lat, lon=activity.end_latlng.lon
)
Expand Down Expand Up @@ -546,7 +546,7 @@ def write_ride_efforts(strava_activity, ride):
# if strava_activity.map.polyline:
# latlon_points = PolylineCodec().decode(strava_activity.map.polyline)
# lonlat_points = [(lon,lat) for (lat,lon) in latlon_points]
# gps_track = WKTSpatialElement(wktutils.linestring_wkt(lonlat_points))
# gps_track = WKTElement(wktutils.linestring_wkt(lonlat_points))
# else:
# gps_track = None
#
Expand Down Expand Up @@ -586,7 +586,7 @@ def write_ride_streams(streams, ride):
RideTrack.__table__.delete().where(RideTrack.ride_id == ride.id)
)

gps_track = WKTSpatialElement(wktutils.linestring_wkt(lonlat_points))
gps_track = WKTElement(wktutils.linestring_wkt(lonlat_points))

ride_track = RideTrack()
ride_track.gps_track = gps_track
Expand Down
32 changes: 21 additions & 11 deletions freezing/web/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,33 @@
import datetime
import subprocess

from freezing.web.autolog import log


# Thanks https://stackoverflow.com/a/21901260/424301
def get_git_revision_short_hash() -> str:
return (
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
.decode("ascii")
.strip()
)
try:
return (
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
.decode("ascii")
.strip()
)
except Exception as e:
log.warning(f"Could not get revision from git {e}")
return "unknown"


def get_git_branch() -> str:
return (
subprocess.check_output(["git", "symbolic-ref", "-q", "HEAD"])
.decode("ascii")
.strip()
.replace("refs/heads/", "")
)
try:
return (
subprocess.check_output(["git", "symbolic-ref", "-q", "HEAD"])
.decode("ascii")
.strip()
.replace("refs/heads/", "")
)
except Exception as e:
log.warning(f"Could not get branch from git {e}")
return "unknown"


def freeze():
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Flask==3.1.0
GeoAlchemy @ https://github.com/hozn/GeoAlchemy/archive/0.7.3dev1.tar.gz
GeoAlchemy2==0.16.0
PyMySQL==1.1.1
PyYAML==6.0.2
SQLAlchemy==1.3.24
SQLAlchemy==1.4.54
# Thanks https://stackoverflow.com/a/77214086/424301 - Flask did not pin Werkzeug dep
Werkzeug==3.1.3
arrow==0.15.5
autoflake==2.2.1
beautifulsoup4==4.12.3
colorlog==4.1.0
envparse==0.2.0
freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.8.6.tar.gz
freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.10.4.tar.gz
geojson==2.5.0
gunicorn==23.0.0
marshmallow==3.23.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

install_req = [
"Flask",
"GeoAlchemy",
"GeoAlchemy2",
"PyMySQL",
"PyYAML",
"alembic",
Expand Down

0 comments on commit a4802f7

Please sign in to comment.