-
Notifications
You must be signed in to change notification settings - Fork 0
/
donorTypesByTimeFrame.py
45 lines (38 loc) · 1.45 KB
/
donorTypesByTimeFrame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
This is the module and supports all the REST actions for the data
"""
from flask import (
make_response,
abort,
)
from config import db
from models import (
VW_INT_Agg_MonthlyDonorsPerLocation,
VW_INT_Agg_MonthlyDonorsPerLocationSchema,
VW_INT_Agg_DailyDonorsPerLocation,
VW_INT_Agg_DailyDonorsPerLocationSchema,
)
def read_all_daily():
"""
This function responds to a request for /api/people
with the complete lists of people
:return: json string of list of people
"""
# Create the list of people from our data
dailyDonors = VW_INT_Agg_DailyDonorsPerLocation.query.order_by(VW_INT_Agg_DailyDonorsPerLocation.yearmonthdayNum).all()
# Serialize the data for the response
dailyDonors_schema = VW_INT_Agg_DailyDonorsPerLocationSchema(many=True)
data = dailyDonors_schema.dump(VW_INT_Agg_DailyDonorsPerLocation).data
return data
def read_all_monthly():
"""
This function responds to a request for /api/people
with the complete lists of people
:return: json string of list of people
"""
# Create the list of people from our data
monthlyDonors = VW_INT_Agg_MonthlyDonorsPerLocation.query.order_by(VW_INT_Agg_MonthlyDonorsPerLocation.yearmonthNum).all()
# Serialize the data for the response
monthlyDonors_schema = VW_INT_Agg_MonthlyDonorsPerLocationSchema(many=True)
data = monthlyDonors_schema.dump(VW_INT_Agg_MonthlyDonorsPerLocation).data
return data