Files
citrus-cms/resources/views/admin-ajax/test-cron-report-builder.blade.php
T
2026-04-28 21:15:09 +03:00

117 lines
4.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use Illuminate\Support\Facades\Cache;
// Test için cache'i temizle
if (isset($_GET['clear_cache'])) {
$documentTemplates = DB::table("document_templates")->where("y", "1")->get();
foreach ($documentTemplates as $template) {
$cacheKey = "cron_report_builder_template_{$template->id}";
$progressCacheKey = "cron_report_builder_progress_{$template->id}";
Cache::forget($cacheKey);
Cache::forget($progressCacheKey);
}
Cache::forget('cron_report_builder_overall_progress');
echo "<div class='alert alert-success'>Cache cleared successfully!</div>";
}
// Test için cron job'ı çalıştır
if (isset($_GET['run_test'])) {
echo "<div class='alert alert-info'>Starting cron job test...</div>";
// Cron job'ı çalıştır
ob_start();
include resource_path('views/cron-report-builder-queue.blade.php');
$output = ob_get_clean();
echo "<div class='alert alert-success'>Cron job completed!</div>";
echo "<pre style='background: #f5f5f5; padding: 10px; border-radius: 5px; max-height: 400px; overflow-y: auto;'>";
echo htmlspecialchars($output);
echo "</pre>";
}
?>
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fa fa-cog"></i> Cron Report Builder Test
</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h6>Test Actions</h6>
</div>
<div class="card-body">
<a href="?clear_cache=1" class="btn btn-warning btn-sm mb-2">
<i class="fa fa-trash"></i> Clear All Cache
</a>
<br>
<a href="?run_test=1" class="btn btn-primary btn-sm">
<i class="fa fa-play"></i> Run Test Cron Job
</a>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h6>Current Status</h6>
</div>
<div class="card-body">
<?php
$overallProgress = Cache::get('cron_report_builder_overall_progress', [
'last_run' => 'Never',
'execution_time' => 0,
'status' => 'not_started'
]);
?>
<p><strong>Last Run:</strong> {{ $overallProgress['last_run'] }}</p>
<p><strong>Status:</strong>
@if($overallProgress['status'] == 'completed')
<span class="badge badge-success">Completed</span>
@elseif($overallProgress['status'] == 'timeout')
<span class="badge badge-warning">Timeout</span>
@else
<span class="badge badge-secondary">Not Started</span>
@endif
</p>
<p><strong>Execution Time:</strong> {{ $overallProgress['execution_time'] }} seconds</p>
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h6>Active Templates</h6>
</div>
<div class="card-body">
<?php
$documentTemplates = DB::table("document_templates")->where("y", "1")->get();
if ($documentTemplates->count() > 0) {
echo "<ul>";
foreach ($documentTemplates as $template) {
$cacheKey = "cron_report_builder_template_{$template->id}";
$lastProcessedIndex = Cache::get($cacheKey, 0);
$name = $template->name ?? $template->title ?? 'N/A';
echo "<li><strong>{$name}</strong> (ID: {$template->id}) - Last Index: {$lastProcessedIndex}</li>";
}
echo "</ul>";
} else {
echo "<p class='text-muted'>No active document templates found.</p>";
}
?>
</div>
</div>
</div>
</div>
</div>
</div>