From a9654f00c8fbc9934289d761843ddd071025013f Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 28 Aug 2026 17:20:28 +0000
Subject: [PATCH] =PHPStorm Code Inspection: fixed class reference errors (from getting rid of JVB() and replacing with direct class::getInstance; as well as general code sniffing, etc

---
 inc/rest/routes/QueueRoutes.php |   54 ++++++++++++++++++++----------------------------------
 1 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/inc/rest/routes/QueueRoutes.php b/inc/rest/routes/QueueRoutes.php
index e7fd1d7..366eaf1 100644
--- a/inc/rest/routes/QueueRoutes.php
+++ b/inc/rest/routes/QueueRoutes.php
@@ -1,8 +1,10 @@
 <?php
 namespace JVBase\rest\routes;
 
+use JVBase\Instance;
 use JVBase\managers\Cache;
 use JVBase\managers\queue\Operation;
+use JVBase\managers\queue\Queue;
 use JVBase\rest\Rest;
 use JVBase\rest\Route;
 use JVBase\rest\Response;
@@ -15,15 +17,15 @@
 
 class QueueRoutes extends Rest
 {
+	use Instance;
 	public function __construct()
 	{
 		$this->cacheName = 'queue';
 		$this->cacheTtl = 300;
 		parent::__construct();
+		$this->cache = Cache::for($this->cacheName, 'custom', $this->cacheTtl)->user();
 
-		if (JVB_TESTING) {
-			$this->cache->flush();
-		}
+
 	}
 
 	/**
@@ -91,32 +93,16 @@
 		if (!$user_id) {
 			return $this->unauthorized();
 		}
-		$this->cache = Cache::for('queue')->user();
-		$status = sanitize_text_field($params['status']);
-		$ids = !empty($params['ids'])
-			? array_map('trim', array_map('sanitize_text_field', explode(',', $params['ids'])))
-			: [];
-		$limit = absint($params['limit']);
 
-		$cacheKey = $this->cache->generateKey(compact('user_id', 'status', 'ids', 'limit'));
-		if ($cached = $this->checkHeaders($request, $cacheKey)) {
-			return $cached;
-		}
+		$filters = $this->buildFilters($params);
+		$ops = Queue::getInstance()->getUserOperations($user_id, $filters);
 
-		$data = $this->cache->tag("user:{$user_id}")->remember($cacheKey, function() use ($user_id, $params) {
-			$filters = $this->buildFilters($params);
-			$operations = JVB()->queue()->getUserOperations($user_id, $filters);
-
-			return [
-				'items' => array_map([$this, 'formatOperation'], $operations),
-				'total' => count($operations),
-				'queue_stats' => $this->getQueueStats($user_id),
-				'server_time' => date('c'),
-			];
-		});
-
-		$response = Response::success($data);
-		return $this->addCacheHeaders($response);
+		return Response::success([
+			'items'	=> array_map([$this, 'formatOperation'], $ops),
+			'total'	=> count($ops),
+			'queue_stats' => $this->getQueueStats($user_id),
+			'server_time'	=> date('c')
+		]);
 	}
 
 	private function buildFilters(array $params): array
@@ -168,7 +154,7 @@
 		}
 
 		// Get operations via Queue - verifies ownership
-		$operations = JVB()->queue()->getUserOperations($user_id, [
+		$operations = Queue::getInstance()->getUserOperations($user_id, [
 			'ids' => $ids,
 			'limit' => count($ids),
 		]);
@@ -202,7 +188,7 @@
 			$filters['ids'] = array_map('trim', explode(',', $ids));
 		}
 
-		$operations = JVB()->queue()->getUserOperations($userId, $filters);
+		$operations = Queue::getInstance()->getUserOperations($userId, $filters);
 
 		if ($since) {
 			$sinceTime = strtotime($since);
@@ -235,7 +221,7 @@
 			return $this->unauthorized();
 		}
 		$this->cache = Cache::for($user_id.'_queue');
-		$operations = JVB()->queue()->getUserOperations($user_id, [
+		$operations = Queue::getInstance()->getUserOperations($user_id, [
 			'state' => 'completed',
 			'outcome' => ['failed', 'failed_permanent', 'partial'],
 			'has_errors' => true,
@@ -265,13 +251,13 @@
 		}
 		$this->cache = Cache::for($userId.'_queue');
 
-		$op = JVB()->queue()->get($id);
+		$op = Queue::getInstance()->get($id);
 
 		if (!$op || $op->userId !== $userId) {
 			return Response::notFound('Operation not found');
 		}
 
-		return Response::item($this->formatOperation($op, true), 'operation');
+		return Response::item($this->formatOperation($op), 'operation');
 	}
 
 
@@ -282,7 +268,7 @@
 	{
 		return array_merge(
 			['queued' => 0, 'localProcessing' => 0, 'uploading' => 0],
-			JVB()->queue()->getUserStats($userId)
+			Queue::getInstance()->getUserStats($userId)
 		);
 	}
 
@@ -390,7 +376,7 @@
 
 	private function processAction(string $action, array $operations, int $userId): array
 	{
-		$queue = JVB()->queue();
+		$queue = Queue::getInstance();
 		$processed = 0;
 		$processedIds = [];
 

--
Gitblit v1.10.0