mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:01:24 +00:00
Fix phpstan reported errors
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Categorization;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Services\Categorization\Pipes\AbstractCategorizationPipe;
|
||||
|
||||
/**
|
||||
@@ -79,6 +80,55 @@ class CategorizationService
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare pipeline categorization against the legacy Blacklight\Categorize class.
|
||||
*
|
||||
* Returns an array with 'pipeline', 'legacy', and 'match' keys so callers
|
||||
* can verify the new pipeline produces the same results as the old categorizer.
|
||||
*
|
||||
* @param int|string $groupId The usenet group ID
|
||||
* @param string $releaseName The name of the release
|
||||
* @return array{pipeline: array{category_id: int, category_name: string}, legacy: array{category_id: int, category_name: string}, match: bool}
|
||||
*/
|
||||
public function compare(int|string $groupId, string $releaseName): array
|
||||
{
|
||||
// Run the new pipeline categorization
|
||||
$pipelineResult = $this->determineCategory($groupId, $releaseName);
|
||||
$pipelineCategoryId = $pipelineResult['categories_id'];
|
||||
$pipelineCategory = Category::find($pipelineCategoryId);
|
||||
$pipelineCategoryName = $pipelineCategory ? $pipelineCategory->title : 'Unknown';
|
||||
|
||||
// Attempt legacy categorization if the class still exists
|
||||
$legacyCategoryId = Category::OTHER_MISC;
|
||||
$legacyCategoryName = 'Unknown';
|
||||
|
||||
if (class_exists(\Blacklight\Categorize::class)) {
|
||||
try {
|
||||
$legacy = new \Blacklight\Categorize;
|
||||
/** @var int $legacyCategoryId */
|
||||
$legacyCategoryId = (int) $legacy->determineCategory($groupId, $releaseName);
|
||||
$legacyCategory = Category::find($legacyCategoryId);
|
||||
$legacyCategoryName = $legacyCategory ? $legacyCategory->title : 'Unknown';
|
||||
} catch (\Throwable) {
|
||||
$legacyCategoryName = 'Legacy error';
|
||||
}
|
||||
} else {
|
||||
$legacyCategoryName = 'Legacy unavailable';
|
||||
}
|
||||
|
||||
return [
|
||||
'pipeline' => [
|
||||
'category_id' => $pipelineCategoryId,
|
||||
'category_name' => $pipelineCategoryName,
|
||||
],
|
||||
'legacy' => [
|
||||
'category_id' => $legacyCategoryId,
|
||||
'category_name' => $legacyCategoryName,
|
||||
],
|
||||
'match' => $pipelineCategoryId === $legacyCategoryId,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get statistics about categorizer usage.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user