From d4d5994c2fc2b955b1fc33a9e126a1423748147e Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 11 Apr 2023 18:36:29 +0700 Subject: [PATCH 1/2] TSK-1131: Remove done state TSK-1130: Try to reduce memory usage on server. Signed-off-by: Andrey Sobolev --- models/recruit/src/index.ts | 3 +-- packages/core/src/client.ts | 4 ++-- pods/backup/Dockerfile | 2 +- pods/server/Dockerfile | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 35317c3b913..2dde5ec771d 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -606,10 +606,9 @@ export function createModel (builder: Builder): void { } const applicantViewOptions: ViewOptionsModel = { - groupBy: ['state', 'doneState', 'assignee', 'space'], + groupBy: ['state', 'assignee', 'space'], orderBy: [ ['state', SortingOrder.Ascending], - ['doneState', SortingOrder.Ascending], ['modifiedOn', SortingOrder.Descending], ['dueDate', SortingOrder.Descending], ['rank', SortingOrder.Ascending] diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 3e24764d28b..37ca37d4fee 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -24,7 +24,7 @@ import { SortingOrder } from './storage' import { Tx, TxCreateDoc, TxProcessor, TxUpdateDoc } from './tx' import { toFindResult } from './utils' -const transactionThreshold = 3000 +const transactionThreshold = 500 /** * @public @@ -193,7 +193,7 @@ export async function createClient ( // Find all new transactions and apply await loadModel(conn, loadedTxIds, allowedPlugins, configs, hierarchy, model) - // We need to look for last 1000 transactions and if it is more since lastTx one we receive, we need to perform full refresh. + // We need to look for last {transactionThreshold} transactions and if it is more since lastTx one we receive, we need to perform full refresh. const atxes = await conn.findAll( core.class.Tx, { modifiedOn: { $gt: lastTx } }, diff --git a/pods/backup/Dockerfile b/pods/backup/Dockerfile index b7d3c783416..95464f104c0 100644 --- a/pods/backup/Dockerfile +++ b/pods/backup/Dockerfile @@ -6,4 +6,4 @@ WORKDIR /usr/src/app COPY bundle.js ./ EXPOSE 3000 -CMD [ "node", "--enable-source-maps", "bundle.js" ] +CMD [ "node", "bundle.js" ] diff --git a/pods/server/Dockerfile b/pods/server/Dockerfile index 295785e977c..9611dcf66b1 100644 --- a/pods/server/Dockerfile +++ b/pods/server/Dockerfile @@ -5,4 +5,4 @@ WORKDIR /usr/src/app COPY bundle.js ./ EXPOSE 8080 -CMD [ "node", "--enable-source-maps", "bundle.js" ] +CMD [ "node", "bundle.js" ] From 02d4a3bbf210edd80c2191c5ada441f74b8a616f Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 11 Apr 2023 19:18:39 +0700 Subject: [PATCH 2/2] TSK-1101: Fix search in Applications Signed-off-by: Andrey Sobolev --- server/core/src/fulltext.ts | 17 +++++++++++++++-- server/core/src/indexer/field.ts | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/server/core/src/fulltext.ts b/server/core/src/fulltext.ts index c4888c7176c..5fc280edad5 100644 --- a/server/core/src/fulltext.ts +++ b/server/core/src/fulltext.ts @@ -23,6 +23,7 @@ import core, { FindOptions, FindResult, Hierarchy, + IndexKind, MeasureContext, ObjQueryType, Ref, @@ -128,8 +129,19 @@ export class FullTextIndex implements WithFind { let classes = this.hierarchy.getDescendants(baseClass) const attrs = this.hierarchy.getAllAttributes(_class) + + // We need to filter all non indexed fields from query to make it work properly + const findQuery: DocumentQuery = { + $search: query.$search + } try { - for (const attr of attrs.values()) { + for (const [k, attr] of attrs) { + if (attr.index === IndexKind.FullText) { + const vv = (query as any)[k] + if (vv != null) { + findQuery[k] = vv + } + } if (attr.type._class === core.class.Collection) { // we need attached documents to be in clases const dsc = this.hierarchy.getDescendants(attr.attributeOf) @@ -143,7 +155,8 @@ export class FullTextIndex implements WithFind { classes = classes.filter((it, idx, arr) => arr.indexOf(it) === idx) const fullTextLimit = options?.limit ?? 200 - let { docs, pass } = await this.indexer.search(classes, query, fullTextLimit) + + let { docs, pass } = await this.indexer.search(classes, findQuery, fullTextLimit) if (docs.length === 0 && pass) { docs = [...docs, ...(await this.adapter.search(classes, query, fullTextLimit))] diff --git a/server/core/src/indexer/field.ts b/server/core/src/indexer/field.ts index 347eb1a8c0d..6d327c72b61 100644 --- a/server/core/src/indexer/field.ts +++ b/server/core/src/indexer/field.ts @@ -212,7 +212,7 @@ export class IndexedFieldStage implements FullTextPipelineStage { if (pipeline.hierarchy.isMixin(d) && pipeline.hierarchy.hasMixin(doc, d)) { const mContext = getFullTextContext(pipeline.hierarchy, d) if (mContext.propogate !== undefined) { - propogate = [...mContext.propogate] + propogate = [...propogate, ...mContext.propogate] } } }