Add chunked timeline routing
This commit is contained in:
@@ -890,9 +890,10 @@ function dbnToolsExcerpt(string $text, int $limit = 520): string
|
||||
|
||||
const DBN_TOOLS_EXTRACT_MAX_BYTES = 8 * 1024 * 1024;
|
||||
const DBN_TOOLS_EXTRACT_TEXT_LIMIT = 128000;
|
||||
const DBN_TOOLS_TIMELINE_EXTRACT_TEXT_LIMIT = 600000;
|
||||
const DBN_TOOLS_EXTRACT_ALLOWED_EXTS = ['txt', 'pdf', 'docx'];
|
||||
|
||||
function dbnToolsExtractUploadedFile(array $file): array
|
||||
function dbnToolsExtractUploadedFile(array $file, int $textLimit = DBN_TOOLS_EXTRACT_TEXT_LIMIT): array
|
||||
{
|
||||
$errCode = (int)($file['error'] ?? UPLOAD_ERR_NO_FILE);
|
||||
if ($errCode !== UPLOAD_ERR_OK) {
|
||||
@@ -936,8 +937,9 @@ function dbnToolsExtractUploadedFile(array $file): array
|
||||
}
|
||||
|
||||
$truncated = false;
|
||||
if (mb_strlen($text, 'UTF-8') > DBN_TOOLS_EXTRACT_TEXT_LIMIT) {
|
||||
$text = mb_substr($text, 0, DBN_TOOLS_EXTRACT_TEXT_LIMIT, 'UTF-8');
|
||||
$textLimit = max(1000, min($textLimit, DBN_TOOLS_TIMELINE_EXTRACT_TEXT_LIMIT));
|
||||
if (mb_strlen($text, 'UTF-8') > $textLimit) {
|
||||
$text = mb_substr($text, 0, $textLimit, 'UTF-8');
|
||||
$truncated = true;
|
||||
}
|
||||
|
||||
@@ -947,6 +949,7 @@ function dbnToolsExtractUploadedFile(array $file): array
|
||||
'filename' => $originalName,
|
||||
'chars' => mb_strlen($text, 'UTF-8'),
|
||||
'truncated' => $truncated,
|
||||
'limit' => $textLimit,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user