Skip to content

Commit 523dd43

Browse files
committed
2 parents df0054f + 4a928dc commit 523dd43

File tree

16 files changed

+18188
-325
lines changed

16 files changed

+18188
-325
lines changed

src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _Docker Compose instructions_
1919
- `docker-compose up -d` to bring up the application.
2020
- Scheduler docker will not start. To run the scheduler, use profile flag `production-only` as explained in the Production Environment section.
2121

22-
#### Finally - Run The UI on http://localhost:3000
22+
#### Finally - Run The UI on http://localhost:80
2323

2424
---------------------------------------
2525
Production Environment

src/client/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pull official base image
2-
FROM node:13.12.0-alpine as builder
2+
FROM node:16-alpine as builder
33

44
# set working directory
55
WORKDIR /app

src/client/package-lock.json

Lines changed: 18033 additions & 231 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/src/pages/DataView360/View/components/Adoptions.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class Adoptions extends Component {
3737

3838
getLatestPets(animals) {
3939
const latestPets = _.sortBy(animals, animal => {
40-
return animal.Events.Time
40+
return (animal.Events && animal.Events.Time) ? animal.Events.Time : 1
41+
4142
}).reverse()
4243

4344
return latestPets.slice(0, PET_COUNT)
@@ -46,11 +47,15 @@ class Adoptions extends Component {
4647
createRows(data) {
4748
const result = _.map(data, (row, index) => {
4849
const photo = row.Photos[0]
50+
const eventDate = (row.Events && row.Events.Time) ? moment.unix(row.Events.Time).format("YYYY-MM-DD") : ''
51+
52+
53+
4954
return (
5055
<TableRow key={index}>
5156
<TableCell align="center">{row.Name}</TableCell>
5257
<TableCell align="center">{row.Type}</TableCell>
53-
<TableCell align="center">{moment.unix(row.Events.Time).format("YYYY-MM-DD")}</TableCell>
58+
<TableCell align="center">{eventDate}</TableCell>
5459
<TableCell align="center">{showAnimalAge(row.DOBUnixTime)}</TableCell>
5560
<TableCell align="center">{<img src={photo} alt="animal" style={{ "maxWidth": "100px" }} />}</TableCell>
5661
</TableRow>

src/client/src/pages/DataView360/View/components/SupportOverview.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class SupportOverview extends Component {
2222
}
2323
const rows = [
2424
{ "title": "First Gift Date", "value": data.first_donation_date },
25-
{ "title": "First Gift Amount", "value": `$${data.first_gift_amount}`},
26-
{ "title": "Lifetime Giving", "value": `$${data.total_giving}`},
25+
{ "title": "First Gift Amount", "value": `$${data.first_gift_amount.toFixed(2)}`},
26+
{ "title": "Lifetime Giving", "value": `$${data.total_giving.toFixed(2)}`},
2727
{ "title": "Total # of Gifts", "value": data.number_of_gifts},
28-
{ "title": "Largest Gift", "value": `$${data.largest_gift}`},
28+
{ "title": "Largest Gift", "value": `$${data.largest_gift.toFixed(2)}`},
2929
{ "title": "Recurring Donor?", "value": data.is_recurring ? "Yes" : "No"},
3030
{ "title": "RFM Score", "value": data.rfm_score }
3131
// { "title": "PAWS Legacy Society?", "value": "test" }

src/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ services:
99
volumes:
1010
- postgres:/var/lib/postgresql/data
1111
environment:
12-
POSTGRES_PASSWORD: thispasswordisverysecure
1312
POSTGRES_DB: paws
1413

1514
server:
@@ -53,3 +52,4 @@ services:
5352
volumes:
5453
postgres:
5554
src_archive:
55+
server_logs:

src/helm-chart/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ server:
99
repository: ghcr.io/codeforphilly/paws-data-pipeline/server
1010
pullPolicy: Always
1111
# Overrides the image tag whose default is the chart appVersion.
12-
tag: "2.33"
12+
tag: "2.34"
1313

1414
client:
1515
image:
1616
repository: ghcr.io/codeforphilly/paws-data-pipeline/client
1717
pullPolicy: Always
1818
# Overrides the image tag whose default is the chart appVersion.
19-
tag: "2.33"
19+
tag: "2.34"
2020

2121
db:
2222
image:

src/server/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ RUN chmod +x bin/startServer.sh
3737
WORKDIR /app
3838

3939
RUN useradd -m pawsapp
40+
RUN mkdir -p /app/.pytest_cache/v/cache
41+
RUN chown -R pawsapp:pawsapp /app/.pytest_cache/v/cache
4042
USER pawsapp
4143

4244
CMD bin/startServer.sh

src/server/api/admin_api.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,16 @@ def read_rfm_edges() :
321321
with engine.begin() as connection: # BEGIN TRANSACTION
322322
q_result = connection.execute(q)
323323
if q_result.rowcount == 0:
324-
current_app.logger.warning("No rfm_edge entry found in DB")
324+
current_app.logger.error("No rfm_edge entry found in DB")
325325
return None
326326
else:
327327
edge_string = q_result.fetchone()[0]
328-
edge_dict = json.loads(edge_string) # Convert stored string to dict
328+
try:
329+
edge_dict = json.loads(edge_string) # Convert stored string to dict
330+
except json.decoder.JSONDecodeError:
331+
current_app.logger.error("rfm_edge entry found in DB was malformed")
332+
return None
333+
329334
return edge_dict
330335

331336

@@ -406,11 +411,3 @@ def hit_gdrs():
406411
# d = read_rfm_edges() # read it again
407412
# print("round-trip d is : \n " + str(d) )
408413
# return "OK"
409-
410-
from rfm_funcs.create_scores import create_scores
411-
@admin_api.route("/api/admin/test_create_scores", methods=["GET"])
412-
def hit_create_scores():
413-
current_app.logger.info("Hitting create_scores() ")
414-
tuple_count = create_scores('2021-07-27')
415-
current_app.logger.info("create_scores() processed " + str(tuple_count) + " scores")
416-
return jsonify(200)

src/server/api/common_api.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,17 @@ def get_animals(matching_id):
191191
query_result = connection.execute(query, matching_id=matching_id)
192192
rows = [dict(row) for row in query_result]
193193
if len(rows) > 0:
194-
row = rows[0]
195-
shelterluv_id = row["source_id"]
196-
person_url = f"http://shelterluv.com/api/v1/people/{shelterluv_id}"
197-
person_details = requests.get(person_url, headers={"x-api-key": SHELTERLUV_SECRET_TOKEN}).json()
198-
if "ID" in person_details:
199-
result["person_details"]["shelterluv_short_id"] = person_details["ID"]
200-
animal_ids = person_details["Animal_ids"]
201-
for animal_id in animal_ids:
202-
animal_url = f"http://shelterluv.com/api/v1/animals/{animal_id}"
203-
animal_details = requests.get(animal_url, headers={"x-api-key": SHELTERLUV_SECRET_TOKEN}).json()
204-
result["animal_details"][animal_id] = animal_details
194+
for row in rows:
195+
shelterluv_id = row["source_id"]
196+
person_url = f"http://shelterluv.com/api/v1/people/{shelterluv_id}"
197+
person_details = requests.get(person_url, headers={"x-api-key": SHELTERLUV_SECRET_TOKEN}).json()
198+
if "ID" in person_details:
199+
result["person_details"]["shelterluv_short_id"] = person_details["ID"]
200+
animal_ids = person_details["Animal_ids"]
201+
for animal_id in animal_ids:
202+
animal_url = f"http://shelterluv.com/api/v1/animals/{animal_id}"
203+
animal_details = requests.get(animal_url, headers={"x-api-key": SHELTERLUV_SECRET_TOKEN}).json()
204+
result["animal_details"][animal_id] = animal_details
205205

206206
return result
207207

0 commit comments

Comments
 (0)