nopaque/web/app/query_results/tasks.py

14 lines
431 B
Python
Raw Normal View History

from .. import db
from ..decorators import background
from ..models import QueryResult
@background
def delete_query_result(query_result_id, *args, **kwargs):
with kwargs['app'].app_context():
query_result = QueryResult.query.get(query_result_id)
if query_result is None:
raise Exception('QueryResult {} not found'.format(query_result_id))
query_result.delete()
db.session.commit()