mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
Adding @nested_transactional for transactions that require more than one
db update/insert. Using a savepoint for the multiple transactions allows us to rollback if there is an error when executing the second db transaction. However, this does add a bit of complexity. Developers need to manage the db session when calling multiple nested tranactions. Unit tests have been added to test this functionality and some end to end tests have been done to make sure all transactions are rollback if there is an exception while executing the transaction.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from app import db
|
||||
from app.billing.billing_schemas import (
|
||||
create_or_update_free_sms_fragment_limit_schema,
|
||||
serialize_ft_billing_remove_emails,
|
||||
@@ -83,6 +84,7 @@ def get_free_sms_fragment_limit(service_id):
|
||||
annual_billing = dao_create_or_update_annual_billing_for_year(service_id,
|
||||
annual_billing.free_sms_fragment_limit,
|
||||
financial_year_start)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify(annual_billing.serialize_free_sms_items()), 200
|
||||
|
||||
@@ -118,3 +120,4 @@ def update_free_sms_fragment_limit_data(service_id, free_sms_fragment_limit, fin
|
||||
free_sms_fragment_limit,
|
||||
financial_year_start
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user