republish valid cookie
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import datetime
|
||||
import logging
|
||||
import time
|
||||
|
||||
from pymongo import MongoClient
|
||||
|
||||
@@ -82,5 +83,29 @@ class MongoDbManager:
|
||||
self.logger.info(error)
|
||||
return link_list
|
||||
|
||||
def link_validated_for_result(self, link: str, linkPojo: LinkPojo, state=True, is_duplicated=False):
|
||||
print("link_validated_for_result() called with url = " + link)
|
||||
if is_duplicated:
|
||||
_id = link.split("/")[-2]
|
||||
else:
|
||||
_id = link.split("/")[-1]
|
||||
print("link_validated_for_result() called with id = " + _id)
|
||||
|
||||
collection_name = str(datetime.date.today())
|
||||
print("link_validated_for_result() called with collection_name = " + collection_name)
|
||||
|
||||
collection = self.db[collection_name]
|
||||
validated_at = time.strftime("%H:%M:%S", time.localtime())
|
||||
validated_by = "requests"
|
||||
if is_duplicated:
|
||||
validated_by = "Double"
|
||||
collection.find_one_and_update({'_id': _id}, {
|
||||
"$set": {"url_validated": state, "validated_at": validated_at, "id": _id, "email": linkPojo.email,
|
||||
"validated_by": validated_by}},
|
||||
upsert=True)
|
||||
# remove the link from db
|
||||
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
||||
collection_to_use.delete_one({'_id': linkPojo.email})
|
||||
|
||||
|
||||
MONGO_STORE_MANAGER = MongoDbManager()
|
||||
|
||||
Reference in New Issue
Block a user