Skip to content

Commit 76b8efe

Browse files
Merge main into QA -- updated patron_home_library_code treatment
2 parents 330b1a0 + 6d1cd92 commit 76b8efe

File tree

10 files changed

+451
-396
lines changed

10 files changed

+451
-396
lines changed

.github/workflows/deploy-production.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Checkout repo
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3434

3535
- name: Configure AWS credentials
36-
uses: aws-actions/configure-aws-credentials@v2
36+
uses: aws-actions/configure-aws-credentials@v4
3737
with:
3838
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole
3939
aws-region: us-east-1
4040

4141
- name: Login to Amazon ECR
4242
id: login-ecr
43-
uses: aws-actions/amazon-ecr-login@v1
43+
uses: aws-actions/amazon-ecr-login@v2
4444

4545
- name: Build, tag, and push image to Amazon ECR
4646
env:

.github/workflows/deploy-qa.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Checkout repo
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3434

3535
- name: Configure AWS credentials
36-
uses: aws-actions/configure-aws-credentials@v2
36+
uses: aws-actions/configure-aws-credentials@v4
3737
with:
3838
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole
3939
aws-region: us-east-1
4040

4141
- name: Login to Amazon ECR
4242
id: login-ecr
43-
uses: aws-actions/amazon-ecr-login@v1
43+
uses: aws-actions/amazon-ecr-login@v2
4444

4545
- name: Build, tag, and push image to Amazon ECR
4646
env:

.github/workflows/run-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Run Python unit tests
22

3-
on:
3+
on:
44
pull_request:
5-
actions: [ opened ]
5+
types: [ labeled, unlabeled, opened, reopened, synchronize ]
66

77
jobs:
88
changelog:
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout repo
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919

2020
- name: Set up Python 3.9
2121
uses: actions/setup-python@v4

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2024-06-21 -- v1.1.0
2+
### Fixed
3+
- Handle patron_home_library_code in standardized way (convert empty strings and 'none' to NULL)
4+
15
## 2023-07-12 -- v1.0.1
26
### Fixed
37
- Increase max Sierra query attempts to 10

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ help:
88
@echo "make test"
99
@echo " run associated test suite with pytest"
1010
@echo "make lint"
11-
@echo " lint project files using the flake8 linter"
11+
@echo " lint project files using the black linter"
1212

1313
run:
1414
export ENVIRONMENT=devel; \
1515
python main.py
1616

1717
test:
18-
pytest
18+
pytest tests
1919

2020
lint:
21-
flake8 --exclude *env
21+
black ./ --check --exclude="(env/)|(tests/)"

helpers/query_helper.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
import os
22

3-
_ENVISIONWARE_QUERY = '''
3+
_ENVISIONWARE_QUERY = """
44
SELECT
5-
pcrKey, pcrUserID, pcrMinutesUsed, pcrDateTime, pcrBranch,
6-
pcrArea, pcrUserData1
5+
pcrKey, pcrUserID, pcrMinutesUsed, pcrDateTime, pcrBranch, pcrArea, pcrUserData1
76
FROM strad_bci
87
WHERE pcrDateTime > '{date_time}'
98
OR (pcrDateTime = '{date_time}' AND pcrKey > {key})
10-
ORDER BY pcrDateTime, pcrKey LIMIT {limit};'''
11-
12-
_SIERRA_QUERY = '''
13-
SELECT barcode, id, ptype_code, home_library_code, pcode3
9+
ORDER BY pcrDateTime, pcrKey
10+
LIMIT {limit};"""
11+
12+
_SIERRA_QUERY = """
13+
SELECT
14+
barcode, id, ptype_code, pcode3,
15+
CASE WHEN LENGTH(TRIM(home_library_code)) = 0
16+
OR TRIM(home_library_code) = 'none' THEN NULL
17+
ELSE TRIM(home_library_code) END
1418
FROM sierra_view.patron_view
15-
WHERE barcode IN ({});'''
19+
WHERE barcode IN ({});"""
1620

17-
_REDSHIFT_QUERY = '''
21+
_REDSHIFT_QUERY = """
1822
SELECT patron_id, postal_code, geoid
1923
FROM {table}
20-
WHERE patron_id IN ({ids});'''
24+
WHERE patron_id IN ({ids});"""
2125

2226

2327
def build_envisionware_query(date_time, key):
2428
return _ENVISIONWARE_QUERY.format(
25-
date_time=date_time, key=key,
26-
limit=os.environ['ENVISIONWARE_BATCH_SIZE'])
29+
date_time=date_time, key=key, limit=os.environ["ENVISIONWARE_BATCH_SIZE"]
30+
)
2731

2832

2933
def build_sierra_query(barcodes):

0 commit comments

Comments
 (0)