From 90691ab14fa1bab4b25166ba4af27ae1cc4302b3 Mon Sep 17 00:00:00 2001 From: p0ps Date: Mon, 10 Jun 2019 13:56:18 +0200 Subject: [PATCH] =?UTF-8?q?Add=20queue=5Ftime=20and=20start=5Ftime,=20to?= =?UTF-8?q?=20get=20more=20info=20on=20when=20a=20specific=20qu=E2=80=A6?= =?UTF-8?q?=20(#6717)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add queue_time and start_time, to get more info on when a specific queue item was queued and started. * Add save generic queue items in a FIFO queue. This will replace the fifo queue used currently for the forced and backlog searches. As a more generic approach. --- medusa/generic_queue.py | 15 ++++++++++++++- medusa/search/manual.py | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/medusa/generic_queue.py b/medusa/generic_queue.py index fbdbf63856..0d553e3580 100644 --- a/medusa/generic_queue.py +++ b/medusa/generic_queue.py @@ -18,9 +18,11 @@ class QueuePriorities(object): class GenericQueue(object): - def __init__(self): + def __init__(self, max_history=100): self.currentItem = None self.queue = [] + self.history = [] + self.max_history = max_history self.queue_name = 'QUEUE' self.min_priority = 0 self.lock = threading.Lock() @@ -95,6 +97,7 @@ def sorter(x, y): item=self.currentItem.name, ) self.currentItem.start() + fifo(self.history, self.currentItem, self.max_history) self.amActive = False @@ -108,12 +111,22 @@ def __init__(self, name, action_id=0): self.action_id = action_id self.stop = threading.Event() self.added = None + self.queue_time = datetime.datetime.now() + self.start_time = None def run(self): """Implementing classes should call this.""" self.inProgress = True + self.start_time = datetime.datetime.now() def finish(self): """Implementing Classes should call this.""" self.inProgress = False threading.currentThread().name = self.name + + +def fifo(my_list, item, max_size=100): + """Append item to queue and limit it to 100 items.""" + if len(my_list) >= max_size: + my_list.pop(0) + my_list.append(item) diff --git a/medusa/search/manual.py b/medusa/search/manual.py index 26be0cfb0a..e338119746 100644 --- a/medusa/search/manual.py +++ b/medusa/search/manual.py @@ -101,6 +101,8 @@ def get_episodes(search_thread, searchstatus): ep.status, ep.quality, manually_searched=ep.manually_searched )], + 'queuetime': search_thread.queue_time.isoformat(), + 'starttime': search_thread.start_time.isoformat() if search_thread.start_time else None, }) return results