mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-26 03:14:19 +00:00
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from .. import db
|
|
from ..decorators import background
|
|
from ..models import Corpus, CorpusFile, QueryResult
|
|
|
|
|
|
@background
|
|
def build_corpus(corpus_id, *args, **kwargs):
|
|
app = kwargs['app']
|
|
with app.app_context():
|
|
corpus = Corpus.query.get(corpus_id)
|
|
if corpus is None:
|
|
raise Exception(f'Corpus {corpus_id} not found')
|
|
corpus.build()
|
|
db.session.commit()
|
|
|
|
|
|
@background
|
|
def delete_corpus(corpus_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
corpus = Corpus.query.get(corpus_id)
|
|
if corpus is None:
|
|
raise Exception(f'Corpus {corpus_id} not found')
|
|
corpus.delete()
|
|
db.session.commit()
|
|
|
|
|
|
@background
|
|
def delete_corpus_file(corpus_file_id, *args, **kwargs):
|
|
with kwargs['app'].app_context():
|
|
corpus_file = CorpusFile.query.get(corpus_file_id)
|
|
if corpus_file is None:
|
|
raise Exception(f'Corpus file {corpus_file_id} not found')
|
|
corpus_file.delete()
|
|
db.session.commit()
|
|
|
|
|
|
@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(f'QueryResult {query_result_id} not found')
|
|
query_result.delete()
|
|
db.session.commit()
|