2 Commits c1318a91ab ... 76928eeeee

Author SHA1 Message Date
  blezz-tech 76928eeeee reminder for tickets with status IN_PROCESS 2 weeks ago
  blezz-tech c1318a91ab reminder for tickets with status IN_PROCESS 2 weeks ago
1 changed files with 24 additions and 21 deletions
  1. 24 21
      handlers/st_request_in_process.py

+ 24 - 21
handlers/st_request_in_process.py

@@ -46,34 +46,37 @@ def send_wontfix_notification(user, ticket):
 
 
 
-def process_in_progress_ticket(ticket_list, start_time):
-    tickets=jsreq.requestGetTicket_user(token, config.API_URL+f"tickets/api/ticket_list/{ticket_list.id}")
-    for ticket in tickets:
-        if ticket.status == 131:
-            if ticket.id not in tickets:
-                tickets_nt[ticket.id] = {
-                    "reminders": 0,
-                    "last_date_reminder": start_time
-                }
+def ticket_worker(ticket, start_time):
+    if ticket.status == 131:
+        if ticket.id not in tickets_nt:
+            tickets_nt[ticket.id] = {
+                "reminders": 0,
+                "last_date_reminder": start_time
+            }
+        
+        if (start_time - tickets_nt[ticket.id]["last_date_reminder"]) > DEFAULT_REMINDER_INTERVAL:
+            if IS_INFINITE_REMINDER or tickets_nt[ticket.id]['reminders'] < MAX_REMINDERS:
+                send_reminder("st_request_in_process@ej.sharix-app.org", ticket)
+            else:
+                del tickets_nt[ticket.id] 
+                # Функция смены статуса на WONTFIX
             
-            if (start_time - tickets_nt[ticket.id]["last_date_reminder"]) > DEFAULT_REMINDER_INTERVAL:
-                if IS_INFINITE_REMINDER or tickets_nt[ticket.id]['reminders'] < MAX_REMINDERS:
-                    send_reminder("st_request_in_process@ej.sharix-app.org", ticket)
-                else:
-                    del tickets_nt[ticket.id] 
-                    # Функция смены статуса на WONTFIX
-                
-                tickets_nt[ticket.id]["reminders"] += 1
-                tickets_nt[ticket.id]["last_date_reminder"] += start_time
+            tickets_nt[ticket.id]["reminders"] += 1
+            tickets_nt[ticket.id]["last_date_reminder"] += start_time
+
 
+def ticket_list_worker(ticket_list, start_time):
+    tickets=jsreq.requestGetTicket_user(token, config.API_URL+f"tickets/api/ticket_list/{ticket_list.id}")
+    for ticket in tickets:
+        ticket_worker(ticket, start_time)
 
 def status_changer():
     while True:
-        ticketlists = jsreq.requestGetList(token, config.API_URL + "tickets/api/ticket_list/")
-        for ticketlist in ticketlists:
+        ticket_lists = jsreq.requestGetList(token, config.API_URL + "tickets/api/ticket_list/")
+        for ticket_list in ticket_lists:
             start_time = datetime.now()
             # bot.bot_log(f"{botname} {start_time.strftime('%Y-%m-%d')} Тикет {ticketlist.id} в обработке\n")
-            t1 = threading.Thread(target=process_in_progress_ticket, args=(ticketlist, start_time))
+            t1 = threading.Thread(target=ticket_list_worker, args=(ticket_list, start_time))
             t1.start()
             t1.join()  # Ожидаем завершения обработки тикета
         time.sleep(DEFAULT_CHECK_INTERVAL)