Merge branch 'feature/handle_black_list' into feature/check_results

# Conflicts:
#	src/db/mongo_manager.py
This commit is contained in:
Lei PAN
2022-07-07 09:40:09 +02:00
5 changed files with 49 additions and 9 deletions
+23 -3
View File
@@ -54,6 +54,17 @@ class MongoDbManager:
except Exception as error:
self.logger.info(error)
def get_blacklist_contacts(self) -> list:
collection_name = BLACK_LIST
black_list_contacts = []
try:
collection_to_use = self.db[collection_name]
for document in collection_to_use.find():
black_list_contacts.append(BlackContactPojo.from_firestore_dict(document))
except Exception as error:
self.logger.info(error)
return black_list_contacts
def get_all_successful_items_for_day(self) -> list:
params.oracle_log_sender.send_read_db_event("get_all_successful_items_for_day")
collection_name = str(datetime.date.today())
@@ -96,9 +107,18 @@ class MongoDbManager:
except Exception as error:
self.logger.info(error)
def remove_contact_from_black_list(self, contact: ContactPojo):
collection_name = BLACK_LIST
collection = self.db[collection_name]
to_delete = {'_id': contact.mail}
try:
collection.delete_one(to_delete)
except Exception as error:
self.logger.info(error)
if __name__ == '__main__':
db_manager = MongoDbManager()
contact = ContactPojo(phone_number='0755667750', passport_number='123456789', last_name='PAN', first_name='Lei',
mail='panleicim@gmail.com')
print(db_manager.insert_blacklist_contact(contact))
black_list = db_manager.get_blacklist_contacts()
for contact in black_list:
print(contact)