<commit_before>import AbstractService from './AbstractService';
import SearchParameters from '../domain/SearchParameters';
import RestApiService from './RestApiService';
import * as Utils from '../utils';
import moment from 'moment';

class AuditService extends AbstractService {

  constructor() {
    super();
  }

  getApiPath() {
    return '/audits';
  }

  /**
   * Get nice labal for audit entity. Audit entity hasn't name.
   * Nicelabel is id and revision date of entity.
   *
   * @param {[type]} entity [description]
   */
  getNiceLabel(entity) {
    if (!entity) {
      return '';
    }
    return entity.id + ' (' + moment(entity.revisionDate).format('d. M. Y  H:mm:ss') + ')';
  }

  /**
   * Returns default searchParameters for current entity type
   *
   * @return {object} searchParameters
   */
  getDefaultSearchParameters() {
    return super.getDefaultSearchParameters().setName(SearchParameters.NAME_QUICK).clearSort().setSort('timestamp', 'DESC');
  }

  getAuditedEntitiesSearchParameters() {
    return super.getDefaultSearchParameters().setName(AuditService.ENTITIES_SEARCH);
  }

  /**
   * Difference between two revision
   */
  getDiffBetweenVersion(firstRevId, secondRevId) {
    return RestApiService.get(this.getApiPath() + `/${firstRevId}/diff/${secondRevId}`)
    .then(response => {
      return response.json();
    })
    .then(json => {
      if (Utils.Response.hasError(json)) {
        throw Utils.Response.getFirstError(json);
      }<commit_msg>#568 fix audit date format<commit_after>import AbstractService from './AbstractService';
import SearchParameters from '../domain/SearchParameters';
import RestApiService from './RestApiService';
import * as Utils from '../utils';
import moment from 'moment';

class AuditService extends AbstractService {

  constructor() {
    super();
  }

  getApiPath() {
    return '/audits';
  }

  /**
   * Get nice labal for audit entity. Audit entity hasn't name.
   * Nicelabel is id and revision date of entity.
   *
   * @param {[type]} entity [description]
   */
  getNiceLabel(entity) {
    if (!entity) {
      return '';
    }
    return entity.id + ' (' + moment(entity.revisionDate).format('D. M. Y  H:mm:ss') + ')';
  }

  /**
   * Returns default searchParameters for current entity type
   *
   * @return {object} searchParameters
   */
  getDefaultSearchParameters() {
    return super.getDefaultSearchParameters().setName(SearchParameters.NAME_QUICK).clearSort().setSort('timestamp', 'DESC');
  }

  getAuditedEntitiesSearchParameters() {
    return super.getDefaultSearchParameters().setName(AuditService.ENTITIES_SEARCH);
  }

  /**
   * Difference between two revision
   */
  getDiffBetweenVersion(firstRevId, secondRevId) {
    return RestApiService.get(this.getApiPath() + `/${firstRevId}/diff/${secondRevId}`)
    .then(response => {
      return response.json();
    })
    .then(json => {
      if (Utils.Response.hasError(json)) {
        throw Utils.Response.getFirstError(json);
      }
{'fraction_non_alphanumeric': 0.1365609348914858, 'fraction_numerical': 0.001001669449081803, 'mean_word_length': 3.5052631578947366, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3435051', 'n_tokens_mistral': 892, 'n_tokens_neox': 880, 'n_words': 196}