-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicGraph.py
More file actions
51 lines (29 loc) · 970 Bytes
/
Copy pathbasicGraph.py
File metadata and controls
51 lines (29 loc) · 970 Bytes
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
46
47
48
49
from connect import db
from models import Transactions
from flask_login import current_user
from datetime import datetime
from sqlalchemy import func
import numpy as np
today = datetime.today()
def expenditure(mydate):
amount = 0
uid = current_user.id
for obj in Transactions.query.filter_by(userId = uid).all():
if obj.date.year == today.year and obj.date.month == today.month and obj.date.day <= mydate:
if obj.cashFlow == 2:
amount += obj.amount
return amount
def basic_graph():
x = np.arange(31)
y = [0]*31
uid = current_user.id
for obj in Transactions.query.filter_by(userId = uid).all():
if obj.date.year == today.year and obj.date.month == today.month and obj.cashFlow == 2:
y[obj.date.day] += obj.amount
return x,y
def basic_graph2():
x = np.arange(31)
y = [0]*31
for xi in x:
y[xi] = expenditure(xi)
return x,y