@@ -22,6 +22,9 @@ async def get_queue_items(self, queue_scope):
2222 "queue_manager.py/get_queue_items (%s): Refreshing and fetching queue" ,
2323 queue_scope ,
2424 )
25+
26+ await self ._refresh_queue ()
27+
2528 if queue_scope == "normal" :
2629 queue_items = await self ._get_queue (full_queue = False )
2730 elif queue_scope == "orphans" :
@@ -34,24 +37,17 @@ async def get_queue_items(self, queue_scope):
3437 error = f"Invalid queue_scope: { queue_scope } "
3538 raise ValueError (error )
3639 if logger .isEnabledFor (logging .DEBUG ):
37- logger .debug (
38- "queue_manager.py/get_queue_items (%s): Current queue = %s" ,
39- queue_scope ,
40- self .format_queue (queue_items ),
41- )
40+ logger .debug (f"queue_manager.py/get_queue_items ({ queue_scope } ): Current queue ({ len (queue_items )} items) = { self .format_queue (queue_items )} " )
4241 return queue_items
4342
4443 async def _get_queue (self , * , full_queue = False ):
45- # Step 1: Refresh the queue (now internal)
46- await self ._refresh_queue ()
47-
48- # Step 2: Get the total number of records
44+ # Step 1: Get the total number of records
4945 total_records_count = await self ._get_total_records_count (full_queue )
5046
51- # Step 3 : Get all records using `arr.full_queue_parameter`
47+ # Step 2 : Get all records using `arr.full_queue_parameter`
5248 queue = await self ._get_arr_records (full_queue , total_records_count )
5349
54- # Step 4 : Filter the queue based on delayed items and ignored download clients
50+ # Step 3 : Filter the queue based on delayed items and ignored download clients
5551 queue = self ._filter_out_ignored_statuses (queue )
5652 queue = self ._filter_out_ignored_download_clients (queue )
5753 return self ._add_detail_item_key (queue )
@@ -64,6 +60,7 @@ def _add_detail_item_key(self, queue):
6460
6561 async def _refresh_queue (self ):
6662 # Refresh the queue by making the POST request using an external make_request function
63+ logger .debug ("queue_manager.py/_refresh_queue: Refreshing Queue" )
6764 await make_request (
6865 method = "POST" ,
6966 endpoint = f"{ self .arr .api_url } /command" ,
@@ -75,6 +72,7 @@ async def _refresh_queue(self):
7572 async def _get_total_records_count (self , full_queue ):
7673 # Get the total number of records from the queue using `arr.full_queue_parameter`
7774 params = {self .arr .full_queue_parameter : full_queue }
75+ logger .debug ("queue_manager.py/_get_total_records_count: Getting Total Records Count" )
7876 total_records = await self .fetch_queue_field (params , key = "totalRecords" )
7977 return total_records
8078
@@ -87,6 +85,7 @@ async def _get_arr_records(self, full_queue, total_records_count):
8785 if full_queue :
8886 params |= {self .arr .full_queue_parameter : full_queue }
8987
88+ logger .debug (f"queue_manager.py/_get_arr_records: Getting queue records ({ total_records_count } items)" )
9089 records = await self .fetch_queue_field (params , key = "records" )
9190 return records
9291
0 commit comments