<commit_before>package models

import scala.collection.mutable.ListBuffer
import util.Random._
import models.User


class Group(members: List[User]) {

  private var _members = members



}

class Groups(users: List[User]) {

  private var _users = users.toBuffer;
  private var _groups : List[Group] = Nil


  def groupSize : Int = 3
  /**
   * This will define the members of these groups.
   *
   * @param users
   * @return
   */
  def fillGroups() : List[Group] = {
    //This entire section can be done better. More functional, have to revist this.
    var userCount : Int = _users.size
    System.out.println("userCount")
    System.out.println(userCount)
    do {

      var members = if (_users.size <=  groupSize + (groupSize - 1)) {
        //if there is a remainder in the group size just return the list. This way groups will maintain a min of at least the grpsize
        val members = _users.toList
        _users = _users.drop(groupSize + groupSize - 1)
        userCount = userCount - groupSize -  (groupSize + 1)
        members
      } else {
        //cut the list by the group size
        val members = _users.slice(0, groupSize).toList
        _users = _users.drop(groupSize)
        userCount = userCount - groupSize
        members
      }


      System.out.println("Number of users in this group")
      System.out.println(members.size)

      System.out.println("Members")
      System.out.println(members)
      _groups = _groups:+ new Group(members)
    } while (userCount > 0)

    _groups
  }

  lazy val groups : List[Group] = {
    fillGroups()
  }
<commit_msg>Made grouping logic more readable.<commit_after>package models

import scala.collection.mutable.ListBuffer
import util.Random._
import models.User


class Group(members: List[User]) {

  private var _members = members



}

class Groups(users: List[User]) {

  private var _users = users.toBuffer;
  private var _groups : List[Group] = Nil


  def groupSize : Int = 3
  def maxGroupSize: Int = groupSize + (groupSize - 1)
  /**
   * This will define the members of these groups.
   *
   * @param users
   * @return
   */
  def fillGroups() : List[Group] = {
    //This entire section can be done better. More functional, have to revist this.
    var userCount : Int = _users.size
    System.out.println("userCount")
    System.out.println(userCount)
    do {

      var members = if (_users.size <=  maxGroupSize) {
        //if there is a remainder in the group size just return the list. This way groups will maintain a min of at least the grpsize
        val members = _users.toList
        _users = _users.drop(maxGroupSize)
        userCount = userCount - maxGroupSize
        members
      } else {
        //cut the list by the group size
        val members = _users.slice(0, groupSize).toList
        _users = _users.drop(groupSize)
        userCount = userCount - groupSize
        members
      }


      System.out.println("Number of users in this group")
      System.out.println(members.size)

      System.out.println("Members")
      System.out.println(members)
      _groups = _groups:+ new Group(members)
    } while (userCount > 0)

    _groups
  }

  lazy val groups : List[Group] = {
    fillGroups()
  }

{'fraction_non_alphanumeric': 0.0946910897236883, 'fraction_numerical': 0.003104625892579944, 'mean_word_length': 2.5328947368421053, 'pattern_counts': {'":': 0, '<': 5, '<?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': '732362', 'n_tokens_mistral': 982, 'n_tokens_neox': 944, 'n_words': 304}