diff --git a/src/fime/task_completer.py b/src/fime/task_completer.py index f6db724..8d4064d 100644 --- a/src/fime/task_completer.py +++ b/src/fime/task_completer.py @@ -3,9 +3,8 @@ import sys import threading import traceback from enum import Enum, auto -from functools import reduce +from functools import reduce, partial from queue import Queue, Empty -from urllib.parse import urlparse, parse_qs try: from PySide6 import QtCore, QtWidgets @@ -90,20 +89,18 @@ class TaskCompleter(QtWidgets.QCompleter): ) with self.rif_counter_lock: self.rif_counter += 1 - future.add_done_callback(self.picker_response_callback) + future.add_done_callback(partial(self.picker_response_callback, self.text)) - def picker_response_callback(self, future): + def picker_response_callback(self, text, future): with self.rif_counter_lock: self.rif_counter -= 1 try: result = future.result() - parsed = urlparse(result.request.url) - response_text = parse_qs(parsed.query)["query"][0] issues = reduce(lambda x, y: x + (y["issues"]), result.json()["sections"], []) extracted = list(map(lambda x: f"{x['key']} {x['summaryText']}", issues)) if extracted: self.queue.put({ - "response_text": response_text, + "response_text": text, "result": extracted, }) else: @@ -132,20 +129,18 @@ class TaskCompleter(QtWidgets.QCompleter): ) with self.rif_counter_lock: self.rif_counter += 1 - future.add_done_callback(self.search_response_callback) + future.add_done_callback(partial(self.search_response_callback, self.text)) - def search_response_callback(self, future): + def search_response_callback(self, text, future): with self.rif_counter_lock: self.rif_counter -= 1 try: result = future.result() json_result = result.json() - parsed = urlparse(result.request.url) - response_text = parse_qs(parsed.query)["jql"][0].split()[2] if "issues" in json_result: extracted = list(map(lambda x: f"{x['key']} {x['fields']['summary']}", json_result["issues"])) self.queue.put({ - "response_text": response_text, + "response_text": text, "result": extracted, }) except Exception: