<commit_before>
if Meteor.isClient
  angular.module('kurea.web').controller 'IdleAchievements', [
    '$scope', '$stateParams', '$collection', '$subscribe', 'IdleCollections', 'PageTitle',
    ($scope, $stateParams, $collection, $subscribe, IdleCollections, PageTitle) =>
      $scope._ = window._
      $scope.playerName = $stateParams.playerName

      PageTitle.setTitle "Idle Lands - #{if $stateParams.playerName then "#{$stateParams.playerName} (Achievements)" else "Global Achievements"}"

      $scope.getAchievements = ->
        if $scope.playerName then $scope.player?[0].achievements else $scope.calculatedAchievements

      $scope.calculateAchievements = ->
        achievementFinalList = []
        calculatedAchievements = []

        _.each $scope.players, (player) -> calculatedAchievements.push player.achievements...

        groupedAchievements = _.groupBy calculatedAchievements, 'name'

        _.each (_.keys groupedAchievements), (key) ->
          achievement = groupedAchievements[key][0]
          achievement.achieved = groupedAchievements[key].length
          achievement.percent = (parseInt achievement.achieved / $scope.players.length*100).toFixed 0
          achievementFinalList.push achievement

        sortedAchievements = _.sortBy achievementFinalList, (achievement) -> achievement.name
        $scope.calculatedAchievements = sortedAchievements

      if $scope.playerName
        $subscribe.subscribe 'singlePlayer', $stateParams.playerName
        .then ->
          $collection IdleCollections.IdlePlayers, name: $stateParams.playerName
          .bind $scope, 'player'
      else
        $subscribe.subscribe 'allPlayers'
        .then ->
          $collection IdleCollections.IdlePlayers
          .bind $scope, 'players'

      $scope.$watch 'players', ->
        $scope.calculateAchievements()
  ]<commit_msg>closes #2<commit_after>
if Meteor.isClient
  angular.module('kurea.web').controller 'IdleAchievements', [
    '$scope', '$stateParams', '$collection', '$subscribe', 'IdleCollections', 'PageTitle',
    ($scope, $stateParams, $collection, $subscribe, IdleCollections, PageTitle) =>
      $scope._ = window._
      $scope.playerName = $stateParams.playerName

      PageTitle.setTitle "Idle Lands - #{if $stateParams.playerName then "#{$stateParams.playerName} (Achievements)" else "Global Achievements"}"

      $scope.getAchievements = ->
        if $scope.playerName then $scope.player?[0].achievements else $scope.calculatedAchievements

      $scope.calculateAchievements = ->
        achievementFinalList = []
        calculatedAchievements = []

        _.each $scope.players, (player) -> calculatedAchievements.push player.achievements...

        groupedAchievements = _.groupBy calculatedAchievements, 'name'

        _.each (_.keys groupedAchievements), (key) ->
          achievement = groupedAchievements[key][0]
          achievement.achieved = groupedAchievements[key].length
          achievement.percent = ((parseInt achievement.achieved / $scope.players.length*100).toFixed 0) or '~1'
          achievementFinalList.push achievement

        sortedAchievements = _.sortBy achievementFinalList, (achievement) -> achievement.name
        $scope.calculatedAchievements = sortedAchievements

      if $scope.playerName
        $subscribe.subscribe 'singlePlayer', $stateParams.playerName
        .then ->
          $collection IdleCollections.IdlePlayers, name: $stateParams.playerName
          .bind $scope, 'player'
      else
        $subscribe.subscribe 'allPlayers'
        .then ->
          $collection IdleCollections.IdlePlayers
          .bind $scope, 'players'

      $scope.$watch 'players', ->
        $scope.calculateAchievements()
  ]
{'fraction_non_alphanumeric': 0.11733046286329386, 'fraction_numerical': 0.003767491926803014, 'mean_word_length': 3.223863636363636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '7059367', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1068, 'n_words': 199}