Handle potential transaction errors in get_daily_data method by rolling back the…

… session if in transaction
1 parent 44784a36
......@@ -155,6 +155,9 @@ class Views(BaseView):
}
def get_daily_data(self, table, field, today, filters, typ=None):
#todo ada kemungkinan menyebabkan error ke transaksi yang lain
if PCDBSession.registry().in_transaction():
PCDBSession.rollback()
columns = [field.label("step")]
qry = table.qry_sum(columns) \
.group_by(field)\
......@@ -172,6 +175,8 @@ class Views(BaseView):
dailyAcc = []
dailyAccTrx = []
amt = trx = acc = accTrx = 0
for r in qry:
mapped = r._mapping
step = mapped.get("step","")
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!