<commit_before>/* jslint node: true */
"use strict";

var crypto = require('crypto');
var FieldDoesNotExistError = require('./FieldDoesNotExistError');

function Fields() {}

Fields.prototype.newField = function newField(state) {
  var id = this._newId();
  this[id] = state;
  return id;
};

Fields.prototype.updateField = function updateField(id, state) {
  if (!this[id]) {
    throw new FieldDoesNotExistError(id);
  }

  this[id] = state;
};

Fields.prototype.getField = function getField(id) {
  if (!this[id]) {
    throw new FieldDoesNotExistError(id);
  }

  return this[id];
};

Fields.prototype._newId = function _newId() {
  do {
    var date = new Date().toISOString();
    var id = crypto.createHash('sha1').update(date).digest('hex').substr(0, 7);
  } while(this[id]);

  return id;
};<commit_msg>ajout de logs dans l'api<commit_after>/* jslint node: true */
"use strict";

var crypto = require('crypto');
var FieldDoesNotExistError = require('./FieldDoesNotExistError');

function Fields() {}

Fields.prototype.newField = function newField(state) {
  var id = this._newId();
  this[id] = state;
  console.log('new field created with id #' + id);
  return id;
};

Fields.prototype.updateField = function updateField(id, state) {
  if (!this[id]) {
    throw new FieldDoesNotExistError(id);
  }
  this[id] = state;
  console.log('field with id #' + id + ' updated');
};

Fields.prototype.getField = function getField(id) {
  if (!this[id]) {
    throw new FieldDoesNotExistError(id);
  }

  return this[id];
};

Fields.prototype._newId = function _newId() {
  do {
    var date = new Date().toISOString();
    var id = crypto.createHash('sha1').update(date).digest('hex').substr(0, 7);
  } while(this[id]);

  return id;
};
{'fraction_non_alphanumeric': 0.16465169833045482, 'fraction_numerical': 0.0034542314335060447, 'mean_word_length': 4.2192192192192195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4179764', 'n_tokens_mistral': 600, 'n_tokens_neox': 588, 'n_words': 135}