Remove unnecessary deletes which hare handled by cascade options

This commit is contained in:
Stephan Porada 2020-05-18 14:53:31 +02:00
parent 22114dd464
commit 6f842a1092

View File

@ -241,10 +241,7 @@ class User(UserMixin, db.Model):
''' '''
Delete the user and its corpora and jobs from database and filesystem. Delete the user and its corpora and jobs from database and filesystem.
''' '''
for job in self.jobs:
job.delete()
for corpus in self.corpora:
corpus.delete()
db.session.delete(self) db.session.delete(self)
db.session.commit() db.session.commit()
@ -365,10 +362,7 @@ class Job(db.Model):
''' '''
Delete the job and its inputs and results from the database. Delete the job and its inputs and results from the database.
''' '''
for input in self.inputs:
db.session.delete(input)
for result in self.results:
db.session.delete(result) # TODO: shouldn't this happen through the cascade option?
db.session.delete(self) db.session.delete(self)
db.session.commit() db.session.commit()
@ -528,8 +522,6 @@ class Corpus(db.Model):
'files': {file.id: file.to_dict() for file in self.files}} 'files': {file.id: file.to_dict() for file in self.files}}
def delete(self): def delete(self):
for corpus_file in self.files:
db.session.delete(corpus_file)
db.session.delete(self) db.session.delete(self)
db.session.commit() db.session.commit()