add timestamp prefix with 'ap:' while send appointment request
This commit is contained in:
@@ -37,6 +37,7 @@ class ReserveResultPojo:
|
||||
proxy: str = None
|
||||
ua: str = None
|
||||
current_ip: str = ""
|
||||
timestampInS: list = None
|
||||
|
||||
@staticmethod
|
||||
def from_firestore_dict(source):
|
||||
@@ -129,6 +130,7 @@ class ReserveResultPojo:
|
||||
u'url_validated': self.url_validated,
|
||||
u'proxy': self.proxy,
|
||||
u'current_ip': self.current_ip,
|
||||
u'timestamp_in_s': "-".join(str(x) for x in self.timestampInS),
|
||||
u'ua': self.ua,
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ from typing import Optional
|
||||
import pika
|
||||
|
||||
from db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from mail.lan_mail_helper import check_mail, check_all_need_to_check_emails
|
||||
from mail.mail_reader_all_contacts import find_links_to_validate_from_mail_list
|
||||
from models.ReserveResultPojo import ReserveResultPojo
|
||||
from models.contact_pojo import ContactPojo
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from proxy_manager.proxy_manager import ProxyManager
|
||||
from queue_message.CookiesPublisher import REQUEST_DATA_QUEUE_DE, CookiesPublisher, MORNING_DATA_CACHE
|
||||
from utils.AppLogging import init_logger
|
||||
from workers.cookie_generator import CookiesGenerator
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_logger()
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||
cookiesPublisher = CookiesPublisher(queue_name=MORNING_DATA_CACHE)
|
||||
cookiesPublisher.set_up_connection()
|
||||
cookieGenerator = CookiesGenerator(proxy_manager=ProxyManager(logger=logger), cookiesPublisher=cookiesPublisher,
|
||||
logger=logger)
|
||||
cookieGenerator.run()
|
||||
@@ -64,6 +64,9 @@ class Sender:
|
||||
result.store_type = store_type
|
||||
result.model = model
|
||||
result.created_at = time.strftime("%H:%M:%S", time.localtime())
|
||||
# Add timestampInS to the result object if it exists in received_dict
|
||||
if 'timestampInS' in self.received_dict:
|
||||
result.timestampInS = self.received_dict['timestampInS']
|
||||
collection_name = str(datetime.date.today())
|
||||
MONGO_STORE_MANAGER.insert_reserve_result(collection_name=collection_name, reserve=result)
|
||||
|
||||
@@ -100,6 +103,18 @@ class Sender:
|
||||
self.logger.info("will publish to queue {}".format(new_coolies_str))
|
||||
# upload the cookie to queue
|
||||
self.received_dict['cookiesStr'] = new_coolies_str
|
||||
# Add timestampInS field with current timestamp in seconds as a list
|
||||
current_timestamp = "ap:" + str(int(time.time()))
|
||||
if 'timestampInS' in self.received_dict:
|
||||
# If timestampInS already exists, ensure it's a list and append new timestamp
|
||||
if isinstance(self.received_dict['timestampInS'], list):
|
||||
self.received_dict['timestampInS'].append(current_timestamp)
|
||||
else:
|
||||
# Convert to list if it's not already a list
|
||||
self.received_dict['timestampInS'] = [self.received_dict['timestampInS'], current_timestamp]
|
||||
else:
|
||||
# Create new list with the timestamp
|
||||
self.received_dict['timestampInS'] = [current_timestamp]
|
||||
self.logger.info("body in json:{}".format(json.dumps(self.received_dict)))
|
||||
if self.cookiesPublisher is not None:
|
||||
self.cookiesPublisher.publish_body(json.dumps(self.received_dict))
|
||||
|
||||
Reference in New Issue
Block a user