Skip to content

Commit f0c74e3

Browse files
authored
imp(grouper): remove commented lines (#435)
* imp(grouper): remove commented lines * imp(): remove redundant dependencie
1 parent 1dfb4a5 commit f0c74e3

File tree

3 files changed

+1
-70
lines changed

3 files changed

+1
-70
lines changed

workers/grouper/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"workerType": "grouper",
1111
"dependencies": {
1212
"@types/redis": "^2.8.28",
13-
"@n1ru4l/json-patch-plus": "^0.2.0",
14-
"js-levenshtein": "^1.1.6"
13+
"@n1ru4l/json-patch-plus": "^0.2.0"
1514
}
1615
}

workers/grouper/src/index.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { decodeUnsafeFields, encodeUnsafeFields } from '../../../lib/utils/unsaf
2222
import { MS_IN_SEC } from '../../../lib/utils/consts';
2323
import DataFilter from './data-filter';
2424
import RedisHelper from './redisHelper';
25-
// import levenshtein from 'js-levenshtein';
2625
import { computeDelta } from './utils/repetitionDiff';
2726
import TimeMs from '../../../lib/utils/time';
2827
import { rightTrim } from '../../../lib/utils/string';
@@ -285,36 +284,6 @@ export default class GrouperWorker extends Worker {
285284
* @param event - event to compare
286285
*/
287286
private async findSimilarEvent(projectId: string, event: EventData<EventAddons>): Promise<GroupedEventDBScheme | undefined> {
288-
// const eventsCountToCompare = 60;
289-
// const diffTreshold = 0.35;
290-
291-
// const lastUniqueEvents = await this.findLastEvents(projectId, eventsCountToCompare);
292-
293-
/**
294-
* Trim titles to reduce CPU usage for Levenshtein comparison
295-
*/
296-
// const trimmedEventTitle = hasValue(event.title) ? rightTrim(event.title, MAX_CODE_LINE_LENGTH) : '';
297-
298-
/**
299-
* First try to find by Levenshtein distance
300-
*/
301-
// const similarByLevenshtein = lastUniqueEvents.filter(prevEvent => {
302-
// const trimmedPrevTitle = hasValue(prevEvent.payload.title) ? rightTrim(prevEvent.payload.title, MAX_CODE_LINE_LENGTH) : '';
303-
304-
// if (trimmedEventTitle === '' || trimmedPrevTitle === '') {
305-
// return false;
306-
// }
307-
308-
// const distance = levenshtein(trimmedEventTitle, trimmedPrevTitle);
309-
// const threshold = trimmedEventTitle.length * diffTreshold;
310-
311-
// return distance < threshold;
312-
// }).pop();
313-
314-
// if (similarByLevenshtein) {
315-
// return similarByLevenshtein;
316-
// }
317-
318287
/**
319288
* If no match by Levenshtein, try matching by patterns
320289
*/
@@ -393,31 +362,6 @@ export default class GrouperWorker extends Worker {
393362
5 * TimeMs.MINUTE / MS_IN_SEC);
394363
}
395364

396-
/**
397-
* Returns last N unique events by a project id
398-
*
399-
* @param projectId - where to find
400-
* @param count - how many events to return
401-
* @returns {GroupedEventDBScheme[]} list of the last N unique events
402-
*/
403-
// private findLastEvents(projectId: string, count: number): Promise<GroupedEventDBScheme[]> {
404-
// return this.cache.get(`last:${count}:eventsOf:${projectId}`, async () => {
405-
// return this.eventsDb.getConnection()
406-
// .collection(`events:${projectId}`)
407-
// .find()
408-
// .sort({
409-
// _id: 1,
410-
// })
411-
// .limit(count)
412-
// .toArray();
413-
// },
414-
// /**
415-
// * TimeMs class stores time intervals in milliseconds, however NodeCache ttl needs to be specified in seconds
416-
// */
417-
// /* eslint-disable-next-line @typescript-eslint/no-magic-numbers */
418-
// TimeMs.MINUTE / 1000);
419-
// }
420-
421365
/**
422366
* Decides whether to increase the number of affected users for the repetition and the daily aggregation
423367
*

workers/grouper/tests/index.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,6 @@ describe('GrouperWorker', () => {
457457
});
458458

459459
describe('Grouping', () => {
460-
// test('should group events with partially different titles', async () => {
461-
// await worker.handle(generateTask({ title: 'Some error (but not filly identical) example' }));
462-
// await worker.handle(generateTask({ title: 'Some error (yes, it is not the identical) example' }));
463-
// await worker.handle(generateTask({ title: 'Some error (and it is not identical) example' }));
464-
465-
// const originalEvent = await eventsCollection.findOne({});
466-
467-
// expect((await repetitionsCollection.find({
468-
// groupHash: originalEvent.groupHash,
469-
// }).toArray()).length).toBe(2);
470-
// });
471-
472460
describe('Pattern matching', () => {
473461
beforeEach(() => {
474462
jest.clearAllMocks();

0 commit comments

Comments
 (0)