diff --git a/workers/grouper/package.json b/workers/grouper/package.json index 2703c06d..6e98edc1 100644 --- a/workers/grouper/package.json +++ b/workers/grouper/package.json @@ -10,7 +10,6 @@ "workerType": "grouper", "dependencies": { "@types/redis": "^2.8.28", - "@n1ru4l/json-patch-plus": "^0.2.0", - "js-levenshtein": "^1.1.6" + "@n1ru4l/json-patch-plus": "^0.2.0" } } diff --git a/workers/grouper/src/index.ts b/workers/grouper/src/index.ts index 4a2809aa..222b1caa 100644 --- a/workers/grouper/src/index.ts +++ b/workers/grouper/src/index.ts @@ -23,7 +23,6 @@ import HawkCatcher from '@hawk.so/nodejs'; import { MS_IN_SEC } from '../../../lib/utils/consts'; import DataFilter from './data-filter'; import RedisHelper from './redisHelper'; -// import levenshtein from 'js-levenshtein'; import { computeDelta } from './utils/repetitionDiff'; import TimeMs from '../../../lib/utils/time'; import { rightTrim } from '../../../lib/utils/string'; @@ -287,36 +286,6 @@ export default class GrouperWorker extends Worker { * @param event - event to compare */ private async findSimilarEvent(projectId: string, event: EventData): Promise { - // const eventsCountToCompare = 60; - // const diffTreshold = 0.35; - - // const lastUniqueEvents = await this.findLastEvents(projectId, eventsCountToCompare); - - /** - * Trim titles to reduce CPU usage for Levenshtein comparison - */ - // const trimmedEventTitle = hasValue(event.title) ? rightTrim(event.title, MAX_CODE_LINE_LENGTH) : ''; - - /** - * First try to find by Levenshtein distance - */ - // const similarByLevenshtein = lastUniqueEvents.filter(prevEvent => { - // const trimmedPrevTitle = hasValue(prevEvent.payload.title) ? rightTrim(prevEvent.payload.title, MAX_CODE_LINE_LENGTH) : ''; - - // if (trimmedEventTitle === '' || trimmedPrevTitle === '') { - // return false; - // } - - // const distance = levenshtein(trimmedEventTitle, trimmedPrevTitle); - // const threshold = trimmedEventTitle.length * diffTreshold; - - // return distance < threshold; - // }).pop(); - - // if (similarByLevenshtein) { - // return similarByLevenshtein; - // } - /** * If no match by Levenshtein, try matching by patterns */ @@ -395,31 +364,6 @@ export default class GrouperWorker extends Worker { 5 * TimeMs.MINUTE / MS_IN_SEC); } - /** - * Returns last N unique events by a project id - * - * @param projectId - where to find - * @param count - how many events to return - * @returns {GroupedEventDBScheme[]} list of the last N unique events - */ - // private findLastEvents(projectId: string, count: number): Promise { - // return this.cache.get(`last:${count}:eventsOf:${projectId}`, async () => { - // return this.eventsDb.getConnection() - // .collection(`events:${projectId}`) - // .find() - // .sort({ - // _id: 1, - // }) - // .limit(count) - // .toArray(); - // }, - // /** - // * TimeMs class stores time intervals in milliseconds, however NodeCache ttl needs to be specified in seconds - // */ - // /* eslint-disable-next-line @typescript-eslint/no-magic-numbers */ - // TimeMs.MINUTE / 1000); - // } - /** * Decides whether to increase the number of affected users for the repetition and the daily aggregation * diff --git a/workers/grouper/tests/index.test.ts b/workers/grouper/tests/index.test.ts index d3f5649e..cd410fc2 100644 --- a/workers/grouper/tests/index.test.ts +++ b/workers/grouper/tests/index.test.ts @@ -457,18 +457,6 @@ describe('GrouperWorker', () => { }); describe('Grouping', () => { - // test('should group events with partially different titles', async () => { - // await worker.handle(generateTask({ title: 'Some error (but not filly identical) example' })); - // await worker.handle(generateTask({ title: 'Some error (yes, it is not the identical) example' })); - // await worker.handle(generateTask({ title: 'Some error (and it is not identical) example' })); - - // const originalEvent = await eventsCollection.findOne({}); - - // expect((await repetitionsCollection.find({ - // groupHash: originalEvent.groupHash, - // }).toArray()).length).toBe(2); - // }); - describe('Pattern matching', () => { beforeEach(() => { jest.clearAllMocks();