<commit_before>db.puzzle2_round.aggregate([{
  $match: {
    v: {
      $exists: 1
    }
  }
}, {
  $group: {
    _id: {
      $arrayElemAt: [{
        $split: ['$_id', ':']
      }, 1]
    },
    vu: {
      $sum: {
        $cond: [{
          $gt: ['$v', 0]
        }, '$v', 0]
      }
    },
    vd: {
      $sum: {
        $cond: [{
          $lt: ['$v', 0]
        }, {
          $subtract: [0, '$v']
        }, 0]
      }
    }
  }
}, {
  $project: {
    _id: 1,
    vu: 1,
    vd: 1,
    v: {
      $divide: [{
        $subtract: ['$vu', '$vd']
      }, {
        $add: ['$vu', '$vd']
      }]
    }
  }
}, {
  $sort: {
    v: -1
  }
}], {
  allowDiskUse: true
}).forEach(r => {
  db.puzzle2_puzzle.update({_id: r._id},{$set:{
    vote: r.v,
    vd: r.vd,
    vu: r.vu
  }});
});

db.puzzle2_puzzle.update({vu:{$exists:0},vd:{$exists:0}}, {$set:{vote:1,vu:1,vd:0}}, {multi:1});<commit_msg>ensure mongodb ints<commit_after>db.puzzle2_round.aggregate([{
  $match: {
    v: {
      $exists: 1
    }
  }
}, {
  $group: {
    _id: {
      $arrayElemAt: [{
        $split: ['$_id', ':']
      }, 1]
    },
    vu: {
      $sum: {
        $cond: [{
          $gt: ['$v', 0]
        }, '$v', 0]
      }
    },
    vd: {
      $sum: {
        $cond: [{
          $lt: ['$v', 0]
        }, {
          $subtract: [0, '$v']
        }, 0]
      }
    }
  }
}, {
  $project: {
    _id: 1,
    vu: 1,
    vd: 1,
    v: {
      $divide: [{
        $subtract: ['$vu', '$vd']
      }, {
        $add: ['$vu', '$vd']
      }]
    }
  }
}, {
  $sort: {
    v: -1
  }
}], {
  allowDiskUse: true
}).forEach(r => {
  db.puzzle2_puzzle.update({_id: r._id},{$set:{
    vote: r.v,
    vd: NumberInt(r.vd),
    vu: NumberInt(r.vu)
  }});
});

db.puzzle2_puzzle.update({vu:{$exists:0},vd:{$exists:0}}, {$set:{vote:1,vu:NumberInt(1),vd:NumberInt(0)}}, {multi:1});
{'fraction_non_alphanumeric': 0.25950054288816504, 'fraction_numerical': 0.021715526601520086, 'mean_word_length': 1.5212038303693571, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5427439', 'n_tokens_mistral': 866, 'n_tokens_neox': 816, 'n_words': 123}