<commit_before>Travis.RepoController = Travis.Controller.extend
  bindings: []

  init: ->
    @_super.apply this, arguments
    Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)

  updateTimes: ->
    if builds = @get('builds')
      builds.forEach (b) -> b.updateTimes()

    if build = @get('build')
      build.updateTimes()

    if build && jobs = build.get('jobs')
      jobs.forEach (j) -> j.updateTimes()

    Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)

  activate: (action) ->
    @_unbind()
    this["view#{$.camelize(action)}"]()

  viewIndex: ->
    @_bind('repo', 'controllers.reposController.firstObject')
    @_bind('build', 'repo.lastBuild')
    @connectTab('current')

  viewCurrent: ->
    @connectTab('current')
    @_bind('build', 'repo.lastBuild')

  viewBuilds: ->
    @connectTab('builds')
    @_bind('builds', 'repo.builds')

  viewPullRequests: ->
    @connectTab('pull_requests')
    @_bind('builds', 'repo.pullRequests')

  viewBranches: ->
    @connectTab('branches')
    @_bind('builds', 'repo.branches')

  viewEvents: ->
    @connectTab('events')
    @_bind('events', 'repo.events')

  viewBuild: ->
    @connectTab('build')

  viewJob: ->
    @_bind('build', 'job.build')
    @connectTab('job')

  repoObserver: (->
    repo = @get('repo')
    repo.select() if repo
  ).observes('repo.id')

  connectTab: (tab) ->
    name = if tab == 'current' then 'build' else tab
    viewClass = if name in ['builds', 'branches', 'pull_requests']
      Travis.BuildsView
    else
      Travis["#{$.camelize(name)}View"]

    @set('tab', tab)
    @connectOutlet(outletName: 'pane', controller: this, viewClass: viewClass)

  _bind: (to, from) ->
    @bindings.push Ember.oneWay(this, to, from)

  _unbind: ->
    binding.disconnect(this) for binding in @bindings
    @bindings.length = 0
<commit_msg>Sort builds on builds/PRs/branches tabs<commit_after>Travis.RepoController = Travis.Controller.extend
  bindings: []

  init: ->
    @_super.apply this, arguments
    Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
    @set 'builds', Em.ArrayProxy.create(Em.SortableMixin,
      isLoadedBinding: 'content.isLoaded'
      sortProperties: ['number']
      sortAscending: false
      content: []
    )

  updateTimes: ->
    if builds = @get('builds')
      builds.forEach (b) -> b.updateTimes()

    if build = @get('build')
      build.updateTimes()

    if build && jobs = build.get('jobs')
      jobs.forEach (j) -> j.updateTimes()

    Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)

  activate: (action) ->
    @_unbind()
    this["view#{$.camelize(action)}"]()

  viewIndex: ->
    @_bind('repo', 'controllers.reposController.firstObject')
    @_bind('build', 'repo.lastBuild')
    @connectTab('current')

  viewCurrent: ->
    @connectTab('current')
    @_bind('build', 'repo.lastBuild')

  viewBuilds: ->
    @connectTab('builds')
    @_bind('builds.content', 'repo.builds')

  viewPullRequests: ->
    @connectTab('pull_requests')
    @_bind('builds.content', 'repo.pullRequests')

  viewBranches: ->
    @connectTab('branches')
    @_bind('builds.content', 'repo.branches')

  viewEvents: ->
    @connectTab('events')
    @_bind('events', 'repo.events')

  viewBuild: ->
    @connectTab('build')

  viewJob: ->
    @_bind('build', 'job.build')
    @connectTab('job')

  repoObserver: (->
    repo = @get('repo')
    repo.select() if repo
  ).observes('repo.id')

  connectTab: (tab) ->
    name = if tab == 'current' then 'build' else tab
    viewClass = if name in ['builds', 'branches', 'pull_requests']
      Travis.BuildsView
    else
      Travis["#{$.camelize(name)}View"]

    @set('tab', tab)
    @connectOutlet(outletName: 'pane', controller: this, viewClass: viewClass)

  _bind: (to, from) ->
    @bindings.push Ember.oneWay(this, to, from)

  _unbind: ->
    binding.disconnect(this) for binding in @bindings
    @bindings.clear()

{'fraction_non_alphanumeric': 0.17477931904161412, 'fraction_numerical': 0.00025220680958385876, 'mean_word_length': 3.4461883408071747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, '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': '515765', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1358, 'n_words': 243}