Refactor ArangoDB methods to improve performance and readability

main
lasseedfast 2 years ago
parent 2b7369286b
commit f0432c1cc1
  1. 34
      arango_admin.py

@ -8,11 +8,43 @@ def truncate():
def clear_info_persons():
persons = list(arango.db.collection("persons").all())
for person in persons:
if 'other' in person:
if person['other']:
arango.db.collection('persons').delete(person)
continue
person['info'] = []
person['mentioned_in_interrogation'] = []
arango.db.collection('persons').update(person, merge=False)
clear_info_persons()
def clear_changer_interrogations():
interrogations = list(arango.db.collection("interrogations").all())
for interrogation in interrogations:
interrogation['mentioned_persons'] = []
arango.db.collection('interrogations').update(interrogation, merge=False)
def clean_mentioned_as():
persons = list(arango.db.collection("persons").all())
for person in persons:
if 'mentioned_as' in person:
mentioned_as = []
for i in person['mentioned_as']:
if i not in mentioned_as:
mentioned_as.append(i)
person['mentioned_as'] = mentioned_as
arango.db.collection('persons').update(person, merge=False)
db = arango.db
cursor = db.aql.execute('for doc in rumors return doc')
rumors = list(cursor)
for rumor in rumors:
rumor['class'] = rumor['class'].replace('.', '').strip().lower()
db.collection('rumors').update(rumor, merge=False)
# persons = list(arango.db.collection("persons").all())

Loading…
Cancel
Save