Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions workers/grouper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
56 changes: 0 additions & 56 deletions workers/grouper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -287,36 +286,6 @@ export default class GrouperWorker extends Worker {
* @param event - event to compare
*/
private async findSimilarEvent(projectId: string, event: EventData<EventAddons>): Promise<GroupedEventDBScheme | undefined> {
// 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
*/
Expand Down Expand Up @@ -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<GroupedEventDBScheme[]> {
// 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
*
Expand Down
12 changes: 0 additions & 12 deletions workers/grouper/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading