chore: add detailed debug for inject advanced
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,8 @@
|
|||||||
"allow": [
|
"allow": [
|
||||||
"Bash(mkdir:*)",
|
"Bash(mkdir:*)",
|
||||||
"mcp__serena__activate_project",
|
"mcp__serena__activate_project",
|
||||||
"mcp__serena__find_symbol"
|
"mcp__serena__find_symbol",
|
||||||
|
"Bash(ssh:*)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ final class ContentAdInjector
|
|||||||
private function injectAdvanced(string $content): string
|
private function injectAdvanced(string $content): string
|
||||||
{
|
{
|
||||||
$config = $this->settings['incontent_advanced'] ?? [];
|
$config = $this->settings['incontent_advanced'] ?? [];
|
||||||
|
$debugSteps = []; // DEBUG
|
||||||
|
|
||||||
// Obtener configuracion
|
// Obtener configuracion
|
||||||
$maxAds = (int)($config['incontent_max_total_ads'] ?? 8);
|
$maxAds = (int)($config['incontent_max_total_ads'] ?? 8);
|
||||||
@@ -127,26 +128,31 @@ final class ContentAdInjector
|
|||||||
$priorityMode = $config['incontent_priority_mode'] ?? 'position';
|
$priorityMode = $config['incontent_priority_mode'] ?? 'position';
|
||||||
$format = $config['incontent_format'] ?? 'in-article';
|
$format = $config['incontent_format'] ?? 'in-article';
|
||||||
|
|
||||||
|
$debugSteps['config'] = "maxAds=$maxAds, minSpacing=$minSpacing, priority=$priorityMode"; // DEBUG
|
||||||
|
|
||||||
// PASO 1: Escanear contenido para encontrar todas las ubicaciones
|
// PASO 1: Escanear contenido para encontrar todas las ubicaciones
|
||||||
$locations = $this->scanContent($content);
|
$locations = $this->scanContent($content);
|
||||||
|
$debugSteps['step1_scan'] = count($locations); // DEBUG
|
||||||
|
|
||||||
if (empty($locations)) {
|
if (empty($locations)) {
|
||||||
return $content;
|
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PASO 2: Filtrar por configuracion (enabled)
|
// PASO 2: Filtrar por configuracion (enabled)
|
||||||
$locations = $this->filterByEnabled($locations, $config);
|
$locations = $this->filterByEnabled($locations, $config);
|
||||||
|
$debugSteps['step2_enabled'] = count($locations); // DEBUG
|
||||||
|
|
||||||
if (empty($locations)) {
|
if (empty($locations)) {
|
||||||
return $content;
|
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PASO 3: Aplicar probabilidad deterministica
|
// PASO 3: Aplicar probabilidad deterministica
|
||||||
$postId = get_the_ID() ?: 0;
|
$postId = get_the_ID() ?: 0;
|
||||||
$locations = $this->applyProbability($locations, $config, $postId);
|
$locations = $this->applyProbability($locations, $config, $postId);
|
||||||
|
$debugSteps['step3_probability'] = count($locations); // DEBUG
|
||||||
|
|
||||||
if (empty($locations)) {
|
if (empty($locations)) {
|
||||||
return $content;
|
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PASO 4-5: Filtrar por espaciado y limite (segun priority_mode)
|
// PASO 4-5: Filtrar por espaciado y limite (segun priority_mode)
|
||||||
@@ -155,13 +161,18 @@ final class ContentAdInjector
|
|||||||
} else {
|
} else {
|
||||||
$locations = $this->filterByPositionFirst($locations, $minSpacing, $maxAds);
|
$locations = $this->filterByPositionFirst($locations, $minSpacing, $maxAds);
|
||||||
}
|
}
|
||||||
|
$debugSteps['step4_spacing'] = count($locations); // DEBUG
|
||||||
|
|
||||||
if (empty($locations)) {
|
if (empty($locations)) {
|
||||||
return $content;
|
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ordenar por posicion para insercion correcta
|
// Ordenar por posicion para insercion correcta
|
||||||
usort($locations, fn($a, $b) => $a['position'] <=> $b['position']);
|
usort($locations, fn($a, $b) => $a['position'] <=> $b['position']);
|
||||||
|
$debugSteps['final_ads'] = count($locations); // DEBUG
|
||||||
|
|
||||||
|
// Insertar debug comment
|
||||||
|
$content = '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||||
|
|
||||||
// PASO 6: Insertar anuncios
|
// PASO 6: Insertar anuncios
|
||||||
return $this->insertAds($content, $locations, $format);
|
return $this->insertAds($content, $locations, $format);
|
||||||
|
|||||||
Reference in New Issue
Block a user