<commit_before>import factory from './factories'
import r, {createPool} from '../db/connect'

function getIDMUsers(idmDB) {
  return idmDB.table('users').run()
}

function buildChapters(users) {
  const inviteCodes = [...new Set(users.map(user => user.inviteCode))]
  const inviteCodesObjs = Array.from(inviteCodes.keys())
    .map(i => ({inviteCodes: [inviteCodes[i]]}))

  return factory.buildMany('chapter', inviteCodesObjs, inviteCodesObjs.length)
}

function buildPlayers(users, chapters) {
  const chapterMap = chapters.reduce((curr, chapter) => {
    curr[chapter.inviteCodes[0]] = chapter
    return curr
  }, {})

  const overwriteObjs = users.map(user => {
    return {id: user.id, chapter: chapterMap[user.inviteCode]}
  })

  return factory.buildMany('player', overwriteObjs, overwriteObjs.length)
}

function buildCycles(chapters) {
  const overwriteObjs = []
  chapters.forEach(chapter => {
    const chapterOverwriteObjs = Array.from(Array(10).keys()).map(i => {
      const now = new Date()
      now.setDate(now.getDate() + (7*i))
      return {
        chapter,
        cycleNumber: i + 1,
        startTimestamp: now,
        state: 'GOAL_SELECTION',<commit_msg>fix lint error<commit_after>import factory from './factories'
import r, {createPool} from '../db/connect'

function getIDMUsers(idmDB) {
  return idmDB.table('users').run()
}

function buildChapters(users) {
  const inviteCodes = [...new Set(users.map(user => user.inviteCode))]
  const inviteCodesObjs = Array.from(inviteCodes.keys())
    .map(i => ({inviteCodes: [inviteCodes[i]]}))

  return factory.buildMany('chapter', inviteCodesObjs, inviteCodesObjs.length)
}

function buildPlayers(users, chapters) {
  const chapterMap = chapters.reduce((curr, chapter) => {
    curr[chapter.inviteCodes[0]] = chapter
    return curr
  }, {})

  const overwriteObjs = users.map(user => {
    return {id: user.id, chapter: chapterMap[user.inviteCode]}
  })

  return factory.buildMany('player', overwriteObjs, overwriteObjs.length)
}

function buildCycles(chapters) {
  const overwriteObjs = []
  chapters.forEach(chapter => {
    const chapterOverwriteObjs = Array.from(Array(10).keys()).map(i => {
      const now = new Date()
      now.setDate(now.getDate() + (7 * i))
      return {
        chapter,
        cycleNumber: i + 1,
        startTimestamp: now,
        state: 'GOAL_SELECTION',
{'fraction_non_alphanumeric': 0.1471458773784355, 'fraction_numerical': 0.004228329809725159, 'mean_word_length': 3.9394572025052192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3678153', 'n_tokens_mistral': 784, 'n_tokens_neox': 777, 'n_words': 154}