Skip to content

Commit

Permalink
Merge pull request #51 from ropable/master
Browse files Browse the repository at this point in the history
Update Django minor version
  • Loading branch information
ropable authored Aug 18, 2023
2 parents 036629e + a1f44ab commit 86b7d60
Show file tree
Hide file tree
Showing 5 changed files with 543 additions and 548 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Prepare the base environment.
FROM python:3.9.15-slim-buster as builder_base
FROM python:3.10.12-slim-bookworm as builder_base_caddy
MAINTAINER [email protected]
LABEL org.opencontainers.image.source https://github.com/dbca-wa/caddy

Expand All @@ -10,9 +10,9 @@ RUN apt-get update -y \
&& pip install --upgrade pip

# Install Python libs using poetry.
FROM builder_base as python_libs
FROM builder_base_caddy as python_libs_caddy
WORKDIR /app
ENV POETRY_VERSION=1.2.2
ENV POETRY_VERSION=1.5.1
RUN pip install "poetry==$POETRY_VERSION"
COPY poetry.lock pyproject.toml /app/
RUN poetry config virtualenvs.create false \
Expand Down
9 changes: 5 additions & 4 deletions geocoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ujson
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.sql import text


dot_env = os.path.join(os.getcwd(), '.env')
Expand All @@ -32,7 +33,7 @@ def liveness():

@app.route('/readiness')
def readiness():
sql = 'SELECT 1'
sql = text('SELECT 1')
s = Session()
result = s.execute(sql).fetchone()
s.close()
Expand All @@ -44,7 +45,7 @@ def readiness():
@app.route('/api/<object_id>')
def detail(object_id):
response.content_type = 'application/json'
sql = f"SELECT object_id, address_nice, owner, ST_AsText(centroid), ST_AsText(envelope), ST_AsText(boundary), data FROM shack_address WHERE object_id = '{object_id}'"
sql = text(f"SELECT object_id, address_nice, owner, ST_AsText(centroid), ST_AsText(envelope), ST_AsText(boundary), data FROM shack_address WHERE object_id = '{object_id}'")
s = Session()
result = s.execute(sql).fetchone()
s.close()
Expand Down Expand Up @@ -75,7 +76,7 @@ def geocode():
m = lon_lat.match(point)
if m:
lon, lat = m.groups()
sql = f"SELECT object_id, address_nice, owner, ST_AsText(centroid), ST_AsText(envelope), ST_AsText(boundary), data FROM shack_address WHERE ST_Intersects(boundary, ST_GeomFromEWKT('SRID=4326;POINT({lon} {lat})'))"
sql = text(f"SELECT object_id, address_nice, owner, ST_AsText(centroid), ST_AsText(envelope), ST_AsText(boundary), data FROM shack_address WHERE ST_Intersects(boundary, ST_GeomFromEWKT('SRID=4326;POINT({lon} {lat})'))")
s = Session()
result = s.execute(sql).fetchone()
s.close()
Expand All @@ -96,7 +97,7 @@ def geocode():
# Address query
words = q.split()
words = ' & '.join(words)
sql = f"SELECT address_nice, owner, ST_X(centroid), ST_Y(centroid), object_id FROM shack_address WHERE tsv @@ to_tsquery('{words}')"
sql = text(f"SELECT address_nice, owner, ST_X(centroid), ST_Y(centroid), object_id FROM shack_address WHERE tsv @@ to_tsquery('{words}')")
s = Session()
result = s.execute(sql).fetchmany(int(limit))
s.close()
Expand Down
Loading

0 comments on commit 86b7d60

Please sign in to comment.