feat(pargar): cap inbound mande/document logs after insert

Keep the newest 2000 success rows per inbound type so dumps stop growing from Pargar webhooks, and store compact document payloads instead of full JSON.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-03 10:19:56 +03:30
co-authored by Cursor
parent c802c67e0d
commit 7e6cd92df4
6 changed files with 323 additions and 5 deletions
+22
View File
@@ -906,6 +906,28 @@ class PargarSyncService
];
}
/**
* وب‌هوک سند پرگار را کامل در LONGTEXT نگذار — همان جدول دامپ را باد می‌کند.
*
* @param array<string, mixed> $data
* @param array<string, mixed> $summary
*/
public function compactInboundDocumentData(array $data, array $summary): string
{
$transactions = is_array($data['transactions'] ?? null) ? $data['transactions'] : [];
return (string) json_encode([
'accountName' => $data['accountName'] ?? null,
'accountId' => $data['accountId'] ?? null,
'transactions_count' => count($transactions),
'transactions_fp' => hash('sha256', (string) json_encode($transactions, JSON_UNESCAPED_UNICODE)),
'_summary' => $summary,
'wallet_applied' => false,
'code_build' => 'docs-then-mande-auto',
'payload_compacted' => true,
], JSON_UNESCAPED_UNICODE);
}
private function parsePargarNumber(mixed $value): float
{
if ($value === null || $value === '') {