0.11.21 push w link

This commit is contained in:
SDE
2024-01-16 17:25:40 +03:00
parent 87fbe7852c
commit 59bc25f31c

View File

@@ -8,6 +8,7 @@ from BaseModels.mailSender import admin_send_mail_by_SMTPlib, techSendMail
def get_Dict_for_send_msgs(kwargs, search_owner_type): def get_Dict_for_send_msgs(kwargs, search_owner_type):
print('get_Dict_for_send_msgs')
Dict = { Dict = {
'search_owner_type': search_owner_type 'search_owner_type': search_owner_type
@@ -30,6 +31,8 @@ def get_Dict_for_send_msgs(kwargs, search_owner_type):
def send_push_message_for_found_matches_routes(route, data_Dict): def send_push_message_for_found_matches_routes(route, data_Dict):
print(f'send_push_message_for_found_matches_routes to route id = {route.id}')
if not route.owner.is_authenticated: if not route.owner.is_authenticated:
return None return None
@@ -42,6 +45,7 @@ def send_push_message_for_found_matches_routes(route, data_Dict):
def send_mail_found_matches_routes(route, data_Dict): def send_mail_found_matches_routes(route, data_Dict):
print(f'send_mail_found_matches_routes to route id = {route.id}')
Dict = { Dict = {
'route': route, 'route': route,
@@ -65,6 +69,7 @@ def send_mail_found_matches_routes(route, data_Dict):
def search_matches(for_routes=None): def search_matches(for_routes=None):
print('search_matches')
log = '' log = ''
@@ -80,6 +85,11 @@ def search_matches(for_routes=None):
'from_place', 'to_place', 'cargo_type', 'weight' 'from_place', 'to_place', 'cargo_type', 'weight'
] ]
if for_routes:
msg = f'last hour create routes count = {for_routes.count()}'
else:
msg = f'last hour not create routes'
print(msg)
for route in for_routes: for route in for_routes:
kwargs = {} kwargs = {}
@@ -114,6 +124,8 @@ def search_matches(for_routes=None):
) )
if found_routes: if found_routes:
msg = f'found routes for send messages = {found_routes.count()}'
data_Dict = get_Dict_for_send_msgs(params, found_routes[0].owner_type) data_Dict = get_Dict_for_send_msgs(params, found_routes[0].owner_type)
msg = send_push_message_for_found_matches_routes(route, data_Dict) msg = send_push_message_for_found_matches_routes(route, data_Dict)
if msg: if msg:
@@ -124,6 +136,7 @@ def search_matches(for_routes=None):
except Exception as e: except Exception as e:
msg = f'<br>\n! search_matches Error = {str(e)}' msg = f'<br>\n! search_matches Error = {str(e)}'
print(msg)
log += msg log += msg
mail_sets = get_mail_send_options() mail_sets = get_mail_send_options()