add timestamp prefix with 'ap:' while send appointment request
This commit is contained in:
@@ -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