<commit_before>

// converts document paths to user information.
// Either uses the session information and the exercise to
// generate a valid document path, or it gets a document
// and generates the groupid and exercise from the document.

module.exports = function(config){
  DConv = {
    session2Group: function(session, DB) {
      if(!session || !session.uid){
        return Promise.reject("No session data defined");
      }
      return DB.Groups.getGroupForUser(session.uid).then(function(group){
        return group;
      });
    },
    doc2Group: function(doc){
      var partA = "", partB = "";
      if (doc.s) {
        partA = Object.getOwnPropertyNames(doc.s)[0];
        partB = Object.getOwnPropertyNames(doc.s[partA])[0];
      } else {
        partA = doc.c;
        partB = data.d;
      }
      var data = partB.split(":");
      return {group:data[0], exercise:data[1], number:data[2]};
    },
    group2Doc: function(group, exercise, number) {
      // we want to use as little tables as possible as those are
      // hard to create for RethinkDB AND it is not possible to create Shards
      // and Replicas.
      var partA = config.document;
      var partB = group+":"+exercise+":"+number
      return {a: partA, b: partB};
    }
  };
  return DConv;
};<commit_msg>(fix) Typo in objectname.<commit_after>

// converts document paths to user information.
// Either uses the session information and the exercise to
// generate a valid document path, or it gets a document
// and generates the groupid and exercise from the document.

module.exports = function(config){
  DConv = {
    session2Group: function(session, DB) {
      if(!session || !session.uid){
        return Promise.reject("No session data defined");
      }
      return DB.Groups.getGroupForUser(session.uid).then(function(group){
        return group;
      });
    },
    doc2Group: function(doc){
      var partA = "", partB = "";
      if (doc.s) {
        partA = Object.getOwnPropertyNames(doc.s)[0];
        partB = Object.getOwnPropertyNames(doc.s[partA])[0];
      } else {
        partA = doc.c;
        partB = doc.d;
      }
      var data = partB.split(":");
      return {group:data[0], exercise:data[1], number:data[2]};
    },
    group2Doc: function(group, exercise, number) {
      // we want to use as little tables as possible as those are
      // hard to create for RethinkDB AND it is not possible to create Shards
      // and Replicas.
      var partA = config.document;
      var partB = group+":"+exercise+":"+number
      return {a: partA, b: partB};
    }
  };
  return DConv;
};
{'fraction_non_alphanumeric': 0.12610195477194328, 'fraction_numerical': 0.006132617861249521, 'mean_word_length': 2.580246913580247, 'pattern_counts': {'":': 6, '<': 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': '4707427', 'n_tokens_mistral': 783, 'n_tokens_neox': 782, 'n_words': 241}