Added comments
This commit is contained in:
@@ -25,8 +25,12 @@ def get_portfolio():
|
||||
email = get_email_or_abort_401()
|
||||
|
||||
return_portfolio = []
|
||||
|
||||
# Get all transactions of current user
|
||||
transactions = db.session.execute("SELECT symbol, SUM(count), SUM(price), MAX(time) FROM `transactions` WHERE email = '" + email + "' GROUP BY symbol;").all()
|
||||
|
||||
# If there are no transactions, return empty portfolio
|
||||
# Otherwise calculate portfolio
|
||||
if transactions is not None:
|
||||
for row in transactions:
|
||||
data = {
|
||||
@@ -37,6 +41,7 @@ def get_portfolio():
|
||||
'current_price': 0
|
||||
}
|
||||
|
||||
# Add current share value to portfolio
|
||||
query_share_price = db.session.query(SharePrice).filter_by(symbol=row[0]).order_by(SharePrice.date.desc()).first()
|
||||
if query_share_price is not None:
|
||||
data['current_price'] = query_share_price.as_dict()['price']
|
||||
|
Reference in New Issue
Block a user