rewrite classifier

This commit is contained in:
Andreas Stephanides
2017-08-07 10:20:28 +02:00
parent ff0bdc6d3b
commit 94d8d26187
11 changed files with 411 additions and 98 deletions

View File

@@ -35,3 +35,22 @@ def flatten_threads(thrds, array=[], level=0):
for t in thrds:
array.append(flatten_threads(t,[],1))
return array
def store_threads(thrds):
for t in thrds:
if type(t[0]) is int:
th=db_session.query(MailThread).filter(MailThread.firstmail==t[0]).first()
# Wenn nicht gefunden neuen anlegen
if th == None:
th=MailThread()
th.firstmail=t[0]
elif not th.body == yaml.dump(t): # Ansonsten body vergleichen
th.body=yaml.dump(t) # body zb (27422,27506), (27450,)
th.islabeled=False
th.opened=True
else:
th.body=yaml.dump(t)
db_session.add(th)
db_session.commit()