<commit_before>module.exports = ($scope, $stateParams, RoundsStore, ContributionsStore, AuthService, BucketsStore, round) ->

  ///Lots of this should be abstracted into a service///

  $scope.currentUserId = AuthService.getCurrentUser().id

  $scope.loadContributorDetails = () ->
    RoundsStore.getContributorDetails($scope.round.id, $scope.currentUser.id).then (details) ->
      $scope.myRoundDetails = details
      $scope.round.myAllocationsLeftCents = details.fundsLeftCents
      $scope.round.myAllocationsAmountCents = details.allocationAmountCents
      $scope.status = $scope.round.getStatus()

  $scope.saveContribution = (contribution) ->
    # if we're gonna have a bad time
    if $scope.status == 'warning'
      # gtfo
      return
    contribution.save(ContributionsStore).then ->
      $scope.loadContributorDetails()

  $scope.groupId = $stateParams.groupId
  $scope.status = null

  $scope.round = round
  $scope.loadContributorDetails()

  _.each round.buckets, (bucket, index) ->
    # get current user's contribution
    myContribution = bucket.getMyContribution($scope.currentUserId)
    bucket.getPercentageFunded()
    bucket.getMyContributionPercentage()
    bucket.getGroupContribution()

    $scope.$watch "round.buckets["+index+"].myContribution.amountDollars", (amountDollars, oldAmountDollars) ->

      # if amountDollars is Not a Number (NaN)
      if amountDollars != 0 and not amountDollars
        # don't accept number
        bucket.myContribution.amountDollars = oldAmountDollars

      round.getMyAllocationsLeftCents(round.myAllocationsAmountCents)

      if round.myAllocationsLeftCents < 0
        bucket.myContribution.amountCents += round.myAllocationsLeftCents

      $scope.status = round.getStatus()

      if amountDollars >= 0
        bucket.getMyContributionPercentage()
        # ensure progress bar does not overfill
        bucket.myContributionPercentage = Math.min(bucket.myContributionPercentage, 100 - bucket.groupContributionPercentage)

  round.getMyContributions()

  #Find total cents contributed to round for bucket list sum
  totalCentsContributed = 0
  for bucket in $scope.round.buckets
    totalCentsContributed += bucket.contributionTotalCents

  #Find total round funds for bucket list sum
  roundFundsTotalCents = 0
  for allocation in $scope.round.allocations
    roundFundsTotalCents += allocation.amountCents

  $scope.round.totalAllocable = roundFundsTotalCents / 100
  $scope.round.totalAllocated = totalCentsContributed / 100

  $scope.timeLeft = round.endsAt.fromNow()<commit_msg>remove 'in' / 'ago' from time left (e.g. in 3 days, 3 days ago)<commit_after>module.exports = ($scope, $stateParams, RoundsStore, ContributionsStore, AuthService, BucketsStore, round) ->

  ///Lots of this should be abstracted into a service///

  $scope.currentUserId = AuthService.getCurrentUser().id

  $scope.loadContributorDetails = () ->
    RoundsStore.getContributorDetails($scope.round.id, $scope.currentUser.id).then (details) ->
      $scope.myRoundDetails = details
      $scope.round.myAllocationsLeftCents = details.fundsLeftCents
      $scope.round.myAllocationsAmountCents = details.allocationAmountCents
      $scope.status = $scope.round.getStatus()

  $scope.saveContribution = (contribution) ->
    # if we're gonna have a bad time
    if $scope.status == 'warning'
      # gtfo
      return
    contribution.save(ContributionsStore).then ->
      $scope.loadContributorDetails()

  $scope.groupId = $stateParams.groupId
  $scope.status = null

  $scope.round = round
  $scope.loadContributorDetails()

  _.each round.buckets, (bucket, index) ->
    # get current user's contribution
    myContribution = bucket.getMyContribution($scope.currentUserId)
    bucket.getPercentageFunded()
    bucket.getMyContributionPercentage()
    bucket.getGroupContribution()

    $scope.$watch "round.buckets["+index+"].myContribution.amountDollars", (amountDollars, oldAmountDollars) ->

      # if amountDollars is Not a Number (NaN)
      if amountDollars != 0 and not amountDollars
        # don't accept number
        bucket.myContribution.amountDollars = oldAmountDollars

      round.getMyAllocationsLeftCents(round.myAllocationsAmountCents)

      if round.myAllocationsLeftCents < 0
        bucket.myContribution.amountCents += round.myAllocationsLeftCents

      $scope.status = round.getStatus()

      if amountDollars >= 0
        bucket.getMyContributionPercentage()
        # ensure progress bar does not overfill
        bucket.myContributionPercentage = Math.min(bucket.myContributionPercentage, 100 - bucket.groupContributionPercentage)

  round.getMyContributions()

  #Find total cents contributed to round for bucket list sum
  totalCentsContributed = 0
  for bucket in $scope.round.buckets
    totalCentsContributed += bucket.contributionTotalCents

  #Find total round funds for bucket list sum
  roundFundsTotalCents = 0
  for allocation in $scope.round.allocations
    roundFundsTotalCents += allocation.amountCents

  $scope.round.totalAllocable = roundFundsTotalCents / 100
  $scope.round.totalAllocated = totalCentsContributed / 100

  $scope.timeLeft = round.endsAt.fromNow(true)
{'fraction_non_alphanumeric': 0.0935446463084654, 'fraction_numerical': 0.005798221878623889, 'mean_word_length': 3.952153110047847, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '5011199', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1492, 'n_words': 321}