Skip to content

Commit

Permalink
Merge pull request #39 from cityofaustin/charlie/timeout-bug
Browse files Browse the repository at this point in the history
Parking postgrest timeout bug
  • Loading branch information
Charlie-Henry authored Nov 27, 2024
2 parents 224493f + 67b5a80 commit 38f0b78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions meters/match_field_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_fiserv(pstgrs):
"""
params = {
"select": "id,invoice_id,transaction_date,flowbird_id",
"order": "id",
"order": "id.desc",
"flowbird_id": "is.null",
"transaction_date": "not.is.null",
"invoice_id": "not.is.null",
Expand Down Expand Up @@ -97,7 +97,7 @@ def get_payments(pstgrs, start, end):
"""
params = {
"select": "id,invoice_id,transaction_date,updated_at",
"order": "id",
"order": "id.desc",
"and": f"(updated_at.lte.{end},updated_at.gte.{start})",
}
payments = pstgrs.select(resource="flowbird_payments_raw", params=params)
Expand Down
8 changes: 4 additions & 4 deletions meters/parking_socrata.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@ def batch_upload(start, end, pstgrs, soda, table):
logger.debug(f"Publishing table: {table} to Socrata from {start} to {end}")
paginate = True
offset = 0
chunk_size = 1000
while paginate:
params = {
"select": "*",
"and": f"(updated_at.lte.{end},updated_at.gte.{start})",
"order": "id",
"limit": 1000,
"order": "id.desc",
"limit": chunk_size,
"offset": offset,
}
offset += 1000
offset += chunk_size
response = pstgrs.select(resource=table, params=params, pagination=True)
if len(response) == 0:
paginate = False
Expand All @@ -126,7 +127,6 @@ def main(args):
pstgrs = Postgrest(
POSTGREST_ENDPOINT,
token=POSTGREST_TOKEN,
headers={"Prefer": "return=representation"},
)
# sodapy
soda = Socrata(SO_WEB, SO_TOKEN, username=SO_USER, password=SO_PASS, timeout=500,)
Expand Down

0 comments on commit 38f0b78

Please sign in to comment.