Added comments

This commit is contained in:
2022-04-12 11:36:23 +02:00
parent f47ab2362b
commit 24c2702f10
11 changed files with 132 additions and 57 deletions

View File

@@ -27,6 +27,7 @@ __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file
def add_transaction(data):
email = get_email_or_abort_401()
# Check if required data is available
if not check_if_symbol_data_exists(data):
abort(400, "Symbol missing")
@@ -39,6 +40,7 @@ def add_transaction(data):
if not check_if_price_data_exists(data):
abort(400, "Price missing")
# Add transaction
new_transaction = Transaction(
email=email,
symbol=data['symbol'],
@@ -60,8 +62,11 @@ def get_transaction():
email = get_email_or_abort_401()
return_transactions = []
# Get all transactions
transactions = db.session.query(Transaction).filter_by(email=email).all()
# Iterate over transactions and add them to return_transactions
if transactions is not None:
for row in transactions:
return_transactions.append(row.as_dict())