Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

refactor(server): use more performant custom uniq method instead of lodash (#656)

Corentin Thomasset981731bbe507
diff --git a/apps/papra-server/src/modules/app/auth/auth.models.ts b/apps/papra-server/src/modules/app/auth/auth.models.ts
index dbae870c..b92535b5 100644
--- a/apps/papra-server/src/modules/app/auth/auth.models.ts
+++ b/apps/papra-server/src/modules/app/auth/auth.models.ts
@@ -2,10 +2,9 @@ import type { ApiKey, ApiKeyPermissions } from '../../api-keys/api-keys.types';
import type { Config } from '../../config/config.types';
import type { Context } from '../server.types';
import type { Session } from './auth.types';
-import { uniq } from 'lodash-es';
import { getClientBaseUrl } from '../../config/config.models';
import { createError } from '../../shared/errors/errors';
-import { isNil, isNilOrEmptyString } from '../../shared/utils';
+import { isNil, isNilOrEmptyString, uniq } from '../../shared/utils';
export function getUser({ context }: { context: Context }) {
const userId = context.get('userId');
diff --git a/apps/papra-server/src/modules/ingestion-folders/ingestion-folders.usecases.ts b/apps/papra-server/src/modules/ingestion-folders/ingestion-folders.usecases.ts
index b2885ed5..06f33e22 100644
--- a/apps/papra-server/src/modules/ingestion-folders/ingestion-folders.usecases.ts
+++ b/apps/papra-server/src/modules/ingestion-folders/ingestion-folders.usecases.ts
@@ -10,7 +10,6 @@ import type { TaskServices } from '../tasks/tasks.services';
import { isAbsolute, join, parse } from 'node:path';
import { safely, safelySync } from '@corentinth/chisels';
import chokidar from 'chokidar';
-import { uniq } from 'lodash-es';
import PQueue from 'p-queue';
import picomatch from 'picomatch';
import { DOCUMENT_ALREADY_EXISTS_ERROR_CODE } from '../documents/documents.errors';
@@ -20,7 +19,7 @@ import { isErrorWithCode } from '../shared/errors/errors';
import { createFsServices } from '../shared/fs/fs.services';
import { createLogger } from '../shared/logger/logger';
import { getRootDirPath } from '../shared/path';
-import { isNil } from '../shared/utils';
+import { isNil, uniq } from '../shared/utils';
import { addTimestampToFilename, getAbsolutePathFromFolderRelativeToOrganizationIngestionFolder, getOrganizationIdFromFilePath, isFileInDoneFolder, isFileInErrorFolder, normalizeFilePathToIngestionFolder } from './ingestion-folder.models';
import { createInvalidPostProcessingStrategyError } from './ingestion-folders.errors';
import { getFile } from './ingestion-folders.services';
diff --git a/apps/papra-server/src/modules/tagging-rules/tagging-rules.usecases.ts b/apps/papra-server/src/modules/tagging-rules/tagging-rules.usecases.ts
index 863ad450..f46b6387 100644
--- a/apps/papra-server/src/modules/tagging-rules/tagging-rules.usecases.ts
+++ b/apps/papra-server/src/modules/tagging-rules/tagging-rules.usecases.ts
@@ -9,10 +9,9 @@ import type { TaggingRuleOperatorValidatorRegistry } from './conditions/tagging-
import type { TaggingRulesRepository } from './tagging-rules.repository';
import type { ConditionMatchMode, TaggingRuleField, TaggingRuleOperator } from './tagging-rules.types';
import { safely, safelySync } from '@corentinth/chisels';
-import { uniq } from 'lodash-es';
import { createError } from '../shared/errors/errors';
import { createLogger } from '../shared/logger/logger';
-import { isNil } from '../shared/utils';
+import { isNil, uniq } from '../shared/utils';
import { addTagToDocument } from '../tags/tags.usecases';
import { createTaggingRuleOperatorValidatorRegistry } from './conditions/tagging-rule-conditions.registry';
import { CONDITION_MATCH_MODES } from './tagging-rules.constants';