Fix: {{advice}} prints as-is (no Hindi/AI conversion); fix Schema Diff truncation
This commit is contained in:
parent
5ce3461a0c
commit
1084ef8875
|
|
@ -3253,18 +3253,9 @@ class Opd extends BaseController
|
||||||
$tokens['investigation'] = $formatBlock('Investigation Advised', (string) ($tokens['investigation_raw'] ?? ''));
|
$tokens['investigation'] = $formatBlock('Investigation Advised', (string) ($tokens['investigation_raw'] ?? ''));
|
||||||
$tokens['Prescriber_Remarks'] = $formatBlock('Remarks', (string) ($tokens['Prescriber_Remarks_raw'] ?? ''));
|
$tokens['Prescriber_Remarks'] = $formatBlock('Remarks', (string) ($tokens['Prescriber_Remarks_raw'] ?? ''));
|
||||||
$adviceRaw = trim((string) ($tokens['advice_raw'] ?? ''));
|
$adviceRaw = trim((string) ($tokens['advice_raw'] ?? ''));
|
||||||
$adviceLocalText = trim((string) ($tokens['advice_local'] ?? ''));
|
// Print advice exactly as typed — no AI/Hindi conversion applied.
|
||||||
if ($adviceRaw !== '') {
|
if ($adviceRaw !== '') {
|
||||||
$advLabelHtml = '<span style="font-weight:700;font-size:13px;line-height:1.35;">सलाह (Advice) :</span>';
|
$tokens['advice'] = nl2br(htmlspecialchars($adviceRaw, ENT_QUOTES, 'UTF-8'));
|
||||||
$adviceHtml = '<div style="margin-bottom:4px;">';
|
|
||||||
if ($adviceLocalText !== '') {
|
|
||||||
$adviceHtml .= $advLabelHtml . ' <span lang="hi">' . $adviceLocalText . '</span>';
|
|
||||||
$adviceHtml .= '<div style="font-size:10px;color:#666;margin-top:1px;">(Advice: ' . $adviceRaw . ')</div>';
|
|
||||||
} else {
|
|
||||||
$adviceHtml .= $advLabelHtml . ' ' . $adviceRaw;
|
|
||||||
}
|
|
||||||
$adviceHtml .= '</div>';
|
|
||||||
$tokens['advice'] = $adviceHtml;
|
|
||||||
} else {
|
} else {
|
||||||
$tokens['advice'] = '';
|
$tokens['advice'] = '';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,9 +180,13 @@ class Setup extends BaseController
|
||||||
$maxRuntimeSeconds = 5;
|
$maxRuntimeSeconds = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For analyze: run to full completion — no time or table-count truncation.
|
||||||
|
$analyzeMaxRuntime = $action === 'analyze' ? PHP_INT_MAX : $maxRuntimeSeconds;
|
||||||
|
$analyzeMaxTables = $action === 'analyze' ? 0 : -1; // 0 = unlimited override
|
||||||
|
|
||||||
$startedAt = microtime(true);
|
$startedAt = microtime(true);
|
||||||
|
|
||||||
$syncResult = $this->buildSchemaSyncPlan($startedAt, $maxRuntimeSeconds);
|
$syncResult = $this->buildSchemaSyncPlan($startedAt, $analyzeMaxRuntime, $analyzeMaxTables);
|
||||||
if ($action === 'apply' && empty($syncResult['errors']) && !empty($syncResult['sql'])) {
|
if ($action === 'apply' && empty($syncResult['errors']) && !empty($syncResult['sql'])) {
|
||||||
$maxApplyStatements = (int) env('setup.sync.max_apply_statements_per_run', 75);
|
$maxApplyStatements = (int) env('setup.sync.max_apply_statements_per_run', 75);
|
||||||
if ($maxApplyStatements <= 0) {
|
if ($maxApplyStatements <= 0) {
|
||||||
|
|
@ -695,7 +699,7 @@ class Setup extends BaseController
|
||||||
/**
|
/**
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
private function buildSchemaSyncPlan(float $startedAt, int $maxRuntimeSeconds): array
|
private function buildSchemaSyncPlan(float $startedAt, int $maxRuntimeSeconds, int $maxTablesOverride = -1): array
|
||||||
{
|
{
|
||||||
$errors = [];
|
$errors = [];
|
||||||
$sql = [];
|
$sql = [];
|
||||||
|
|
@ -724,9 +728,14 @@ class Setup extends BaseController
|
||||||
$masterTables = $masterSchema['tables'] ?? [];
|
$masterTables = $masterSchema['tables'] ?? [];
|
||||||
$clientTables = array_flip($client->listTables());
|
$clientTables = array_flip($client->listTables());
|
||||||
|
|
||||||
$maxTables = (int) env('setup.sync.max_tables_per_run', 0);
|
// $maxTablesOverride >= 0 takes precedence over the .env setting (0 = unlimited).
|
||||||
if ($maxTables < 0) {
|
if ($maxTablesOverride >= 0) {
|
||||||
$maxTables = 0;
|
$maxTables = $maxTablesOverride;
|
||||||
|
} else {
|
||||||
|
$maxTables = (int) env('setup.sync.max_tables_per_run', 0);
|
||||||
|
if ($maxTables < 0) {
|
||||||
|
$maxTables = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$processedTables = 0;
|
$processedTables = 0;
|
||||||
$truncated = false;
|
$truncated = false;
|
||||||
|
|
|
||||||
|
|
@ -180,11 +180,20 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Generated SQL</label>
|
<label>Generated SQL</label>
|
||||||
<textarea class="form-control" rows="14" readonly><?php
|
<?php
|
||||||
$sqlLines = $sync_result['sql'] ?? [];
|
$sqlLines = $sync_result['sql'] ?? [];
|
||||||
|
$totalSqlLines = is_array($sqlLines) ? count($sqlLines) : 0;
|
||||||
|
$displayLimit = 2000;
|
||||||
|
?>
|
||||||
|
<?php if ($totalSqlLines > $displayLimit) : ?>
|
||||||
|
<div class="alert alert-warning" style="margin-bottom:4px;">
|
||||||
|
Showing first <?= $displayLimit ?> of <?= $totalSqlLines ?> statements.
|
||||||
|
Use <strong>Apply Sync to Client DB</strong> to execute all statements.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<textarea class="form-control" rows="14" readonly><?php
|
||||||
if (is_array($sqlLines)) {
|
if (is_array($sqlLines)) {
|
||||||
$sqlLines = array_slice($sqlLines, 0, 300);
|
echo esc(implode("\n", array_slice($sqlLines, 0, $displayLimit)));
|
||||||
echo esc(implode("\n", $sqlLines));
|
|
||||||
}
|
}
|
||||||
?></textarea>
|
?></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user