Skip to content

Commit b2caedc

Browse files
committed
fix
1 parent d77577b commit b2caedc

File tree

5 files changed

+17
-90
lines changed

5 files changed

+17
-90
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ RUN apt-get update && \
44
apt-get install -y make && \
55
pip install uv
66

7-
ENV UV_LINK_MODE=copy
87
ENV UV_COMPILE_BYTECODE=1
9-
RUN --mount=type=cache,target=/root/.cache/uv
108

119
WORKDIR /app
1210
COPY . .

Makefile

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,27 @@ dev:
99
run:
1010
uv run gunicorn -w 4 -b 0.0.0.0:$(PORT) app.server:app
1111

12-
start:
13-
make stop rm || true
14-
docker run -p $(PORT):$(PORT) data-charts-api make run
15-
1612
build:
1713
docker build . --tag=data-charts-api
1814

15+
start:
16+
-docker stop data-charts-api
17+
-docker rm data-charts-api
18+
docker run -d --name data-charts-api -p $(PORT):$(PORT) data-charts-api
19+
1920
stop:
20-
docker stop data-charts-api
21+
-docker stop data-charts-api
2122

2223
rm:
23-
docker rm data-charts-api
24+
-docker rm data-charts-api
2425

2526
bash:
2627
docker run --rm -it data-charts-api bash
2728

28-
PID_FILE = server.pid
29-
3029
test:
31-
env PORT=$(PORT) DATABASE_URL=postgres://student:[email protected]:5432/chartsdb \
32-
make dev & echo $$! > $(PID_FILE) && \
33-
sleep 2 && \
34-
uv run pytest; \
35-
status=$$?; \
36-
if [ -f $(PID_FILE) ]; then kill `cat $(PID_FILE)` && rm $(PID_FILE); fi; \
37-
exit $$status
30+
uv run pytest
3831

3932
lint:
4033
uv run ruff check .
4134

42-
check: test lint
35+
check: lint

app/server.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def get_visits():
3737
SELECT *
3838
FROM visits
3939
WHERE visits.datetime BETWEEN (%s) AND (%s);'''
40-
conn = get_db()
41-
with conn.cursor(row_factory=dict_row) as c:
42-
c.execute(query, [begin_date, end_date])
43-
res = c.fetchall()
40+
with get_db() as conn:
41+
with conn.cursor(row_factory=dict_row) as c:
42+
c.execute(query, [begin_date, end_date])
43+
res = c.fetchall()
4444
return res
4545

4646

@@ -57,8 +57,8 @@ def get_registrations():
5757
SELECT *
5858
FROM registrations
5959
WHERE registrations.datetime BETWEEN (%s) AND (%s);'''
60-
conn = get_db()
61-
with conn.cursor(row_factory=dict_row) as c:
62-
c.execute(query, [begin_date, end_date])
63-
res = c.fetchall()
60+
with get_db() as conn:
61+
with conn.cursor(row_factory=dict_row) as c:
62+
c.execute(query, [begin_date, end_date])
63+
res = c.fetchall()
6464
return res

server.pid

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/conftest.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)