Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
Expand Down Expand Up @@ -50,15 +50,15 @@ jobs:
env:
CTMS_DB_URL: postgresql://postgres:postgres@172.17.0.1:5432/postgres # pragma: allowlist secret
CTMS_SECRET_KEY: secret_${{ github.sha }} # pragma: allowlist secret

build_production_image:
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Build production image
- name: Build production image
uses: docker/build-push-action@v6
with:
context: .
Expand Down
18 changes: 12 additions & 6 deletions ctms/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ def count_total_contacts(db: Session) -> int:
This metadata is refreshed on `VACUUM` or `ANALYSIS` which
is run regularly by default on our database instances.
"""
query = text(
"SELECT reltuples AS estimate "
"FROM pg_class "
f"where relname = '{Email.__tablename__}'"
)
result = db.execute(query).scalar()
result = db.execute(
text(
"SELECT reltuples AS estimate "
"FROM pg_class "
f"where relname = '{Email.__tablename__}'"
)
).scalar()
if result is None or result < 0:
# Fall back to a full count if the estimate is not available.
result = db.execute(
text(f"SELECT COUNT(*) FROM {Email.__tablename__}")
).scalar()
if result is None:
return -1
return int(result)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
timeout: 1s
retries: 10
postgres:
image: postgres:12
image: postgres:15
ports:
- 5432:5432
environment:
Expand Down