mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
actor sync
This commit is contained in:
@@ -489,6 +489,90 @@ class ActorController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getMissingStashReports(Request $request, Response $response, $args)
|
||||
{
|
||||
try {
|
||||
$logDir = __DIR__ . '/../../storage/logs';
|
||||
$reports = [];
|
||||
|
||||
if (is_dir($logDir)) {
|
||||
$files = glob($logDir . '/missing_stash_actors_*.json');
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = basename($file);
|
||||
$fileData = json_decode(file_get_contents($file), true);
|
||||
|
||||
if ($fileData) {
|
||||
$reports[] = [
|
||||
'filename' => $filename,
|
||||
'generated_at' => $fileData['generated_at'] ?? 'Unknown',
|
||||
'total_missing' => $fileData['total_missing'] ?? 0,
|
||||
'description' => $fileData['description'] ?? '',
|
||||
'file_path' => $file
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by generation date (newest first)
|
||||
usort($reports, function($a, $b) {
|
||||
return strtotime($b['generated_at']) <=> strtotime($a['generated_at']);
|
||||
});
|
||||
}
|
||||
|
||||
return $this->jsonResponse($response, [
|
||||
'reports' => $reports,
|
||||
'total_reports' => count($reports)
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->jsonResponse($response->withStatus(500), [
|
||||
'error' => 'Internal server error: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function syncExistingPerformers(Request $request, Response $response, $args)
|
||||
{
|
||||
// Set PHP timeouts for long-running operations
|
||||
ini_set('memory_limit', '2G');
|
||||
ini_set('max_execution_time', 0); // Allow unlimited execution time
|
||||
ini_set('max_input_time', 3600); // 1 hour for input processing
|
||||
ini_set('default_socket_timeout', 3600); // 1 hour for socket operations
|
||||
|
||||
// Set headers to prevent timeouts
|
||||
$response = $response->withHeader('X-Accel-Buffering', 'no'); // Disable nginx buffering
|
||||
|
||||
try {
|
||||
// Get Stash configuration from database
|
||||
$stmt = $this->pdo->prepare('SELECT * FROM sources WHERE name = ?');
|
||||
$stmt->execute(['stash']);
|
||||
$stashSource = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$stashSource) {
|
||||
return $this->jsonResponse($response->withStatus(500), [
|
||||
'error' => 'Stash source not configured in database'
|
||||
]);
|
||||
}
|
||||
|
||||
// Create Stash sync service
|
||||
$stashSyncService = new \App\Services\StashSyncService($this->pdo, $stashSource);
|
||||
|
||||
// Run the existing performers sync
|
||||
$results = $stashSyncService->syncExistingPerformers();
|
||||
|
||||
return $this->jsonResponse($response, [
|
||||
'success' => true,
|
||||
'message' => 'Existing performers sync completed',
|
||||
'results' => $results
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->jsonResponse($response->withStatus(500), [
|
||||
'error' => 'Internal server error: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function index(Request $request, Response $response, $args)
|
||||
{
|
||||
$queryParams = $request->getQueryParams();
|
||||
|
||||
Reference in New Issue
Block a user