|
|
|
@ -42,6 +42,34 @@ class ArangoDB: |
|
|
|
string = encoded_string[:254].decode('utf-8', 'ignore') |
|
|
|
string = encoded_string[:254].decode('utf-8', 'ignore') |
|
|
|
return string |
|
|
|
return string |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_persons(self, confirmed=True): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Gets a list of all names in the database. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
|
|
|
|
confirmed (bool, optional): If True, only returns names of confirmed persons. |
|
|
|
|
|
|
|
If False, returns names of all persons. |
|
|
|
|
|
|
|
Defaults to True. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
|
|
|
|
dict: A dictionary containing two lists: |
|
|
|
|
|
|
|
- 'names': A list of all names in the database. |
|
|
|
|
|
|
|
- 'dict_persons': A list of dictionaries, where each dictionary contains the name and key of a person. |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
confirmed_string = '' |
|
|
|
|
|
|
|
if confirmed: |
|
|
|
|
|
|
|
confirmed_string = 'filter person.confirmed == true' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = f""" |
|
|
|
|
|
|
|
FOR person IN persons |
|
|
|
|
|
|
|
{confirmed_string} |
|
|
|
|
|
|
|
RETURN {{'name': person.name, '_key': person._key}} |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
persons = [i for i in self.db.aql.execute(query)] |
|
|
|
|
|
|
|
names = [document['name'] for document in persons] |
|
|
|
|
|
|
|
dict_persons = {document['name']: document['_key'] for document in persons} |
|
|
|
|
|
|
|
return {'names': names, 'dict':dict_persons} |
|
|
|
|
|
|
|
|
|
|
|
arango = ArangoDB() |
|
|
|
arango = ArangoDB() |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
|