<commit_before>import { createSelector } from "reselect";

export const eventsGetter = (state) => state.events.entities;
export const filtersGetter = (state) => state.filters;

export const filteredEventsSelector = createSelector(eventsGetter, filtersGetter, (events, filters) => {
  const { dateFrom, dateTo, level, operationObjectIn, operationObjectOut, userName } = filters;

  return events.filter((event: any) => {
    return event.userName.match(userName) &&
      event.operationObject.in.match(operationObjectIn) &&
      event.operationObject.out.match(operationObjectOut) &&
      (level === "all" ? true : event.level.match(level)) &&
      (dateFrom ? (new Date(event.timestamp)).getTime() >= (new Date(dateFrom)).getTime() : true) &&
      (dateTo ? (new Date(event.timestamp)).getTime() <= (new Date(dateTo)).getTime() : true);
  });
});<commit_msg>add operation type to selector<commit_after>import { createSelector } from "reselect";
import { CERTIFICATE_GENERATION, CERTIFICATE_IMPORT, DECRYPT, ENCRYPT, SIGN } from "../constants";

export const eventsGetter = (state) => state.events.entities;
export const filtersGetter = (state) => state.filters;

export const filteredEventsSelector = createSelector(eventsGetter, filtersGetter, (events, filters) => {
  const { dateFrom, dateTo, level,operations, operationObjectIn, operationObjectOut, userName } = filters;

  return events.filter((event: any) => {
    return event.userName.match(userName) &&
      event.operationObject.in.match(operationObjectIn) &&
      event.operationObject.out.match(operationObjectOut) &&
      (level === "all" ? true : event.level.match(level)) &&
      (dateFrom ? (new Date(event.timestamp)).getTime() >= (new Date(dateFrom)).getTime() : true) &&
      (dateTo ? (new Date(event.timestamp)).getTime() <= (new Date(dateTo)).getTime() : true) &&
      (
        operations[SIGN] && event.operation === "Подпись" ||
        operations[ENCRYPT] && event.operation === "Шифрование" ||
        operations[DECRYPT] && event.operation === "Расшифрование" ||
        operations[CERTIFICATE_GENERATION] && event.operation === "Генерация сертификата" ||
        operations[CERTIFICATE_IMPORT] && event.operation === "Импорт сертификата"
      );
  });
});
{'fraction_non_alphanumeric': 0.15449688334817455, 'fraction_numerical': 0.0, 'mean_word_length': 4.659949622166247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2624641', 'n_tokens_mistral': 669, 'n_tokens_neox': 675, 'n_words': 133}