@@ -22,7 +22,6 @@ import { decodeUnsafeFields, encodeUnsafeFields } from '../../../lib/utils/unsaf
2222import { MS_IN_SEC } from '../../../lib/utils/consts' ;
2323import DataFilter from './data-filter' ;
2424import RedisHelper from './redisHelper' ;
25- // import levenshtein from 'js-levenshtein';
2625import { computeDelta } from './utils/repetitionDiff' ;
2726import TimeMs from '../../../lib/utils/time' ;
2827import { 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 *
0 commit comments