<commit_before>class window.GenericChannelList extends Backbone.Factlink.Collection
  model: Channel

class window.TopChannelList extends window.GenericChannelList
  url: "/t/top_channels"

class window.ChannelList extends window.GenericChannelList
  _.extend @prototype, Backbone.Factlink.ActivatableCollectionMixin

  reloadingEnabled: false

  url: -> "/#{@getUsername()}/channels"

  setUsernameAndRefresh: (username)->
    @setUsername username
    @setupReloading true

  setUsernameAndRefreshIfNeeded: (username)->
    @setUsernameAndRefresh(username) if @getUsername() isnt username or @length == 0

  getUsername: -> if @_username then @_username else

  setUsername: (name) ->
    return false if @_username? and @_username is name

    @reset([])
    @_username = name
    return true

  shouldReload: ->
    getSetting("reload") isnt "false"

  setupReloading: (force_reload_now=false)->
    if @shouldReload()
      if @reloadingEnabled isnt true
        @reloadingEnabled = true
        @_startReloading()
      else if force_reload_now
        @_startReloading()

  _startReloading: ->
    args = arguments

    clearTimeout @_currentTimeout if @_currentTimeout?
    delete @_currentTimeout
    callMyselfSoon = =>
      @_currentTimeout = setTimeout _.bind(args.callee, this), (10*60*1000)-1


    @fetch
      success: (collection, response) =>
        if typeof window.currentChannel isnt "undefined"
          newCurrentChannel = collection.get(currentChannel.id)
          if newCurrentChannel?
            currentChannel.set newCurrentChannel.attributes
        callMyselfSoon()

      error: callMyselfSoon()

  getBySlugTitle: (slug_title)->
    results = @filter (ch)-> ch.get('slug_title') == slug_title
    if results.length == 1 then results[0] else `undefined`

  orderByAuthority: ->
    @comparator = (channel) ->
      -parseFloat(channel.get("created_by_authority"))
    @sort()

  orderedByAuthority: ->
    topchannels = new ChannelList(@models)
    topchannels.orderByAuthority()

    topchannels

  channelArrayForIds: (ids) ->
    array = []
    @each (ch) ->
      if ch.id in ids
        array.push ch.clone()
    array
<commit_msg>Eliminated currentChannel from ChannelList and fixed a memory leak too.<commit_after>class window.GenericChannelList extends Backbone.Factlink.Collection
  model: Channel

class window.TopChannelList extends window.GenericChannelList
  url: "/t/top_channels"

class window.ChannelList extends window.GenericChannelList
  _.extend @prototype, Backbone.Factlink.ActivatableCollectionMixin

  reloadingEnabled: false

  url: -> "/#{@getUsername()}/channels"

  setUsernameAndRefresh: (username)->
    @setUsername username
    @setupReloading true

  setUsernameAndRefreshIfNeeded: (username)->
    @setUsernameAndRefresh(username) if @getUsername() isnt username or @length == 0

  getUsername: -> if @_username then @_username else

  setUsername: (name) ->
    return false if @_username? and @_username is name

    @reset([])
    @_username = name
    return true

  shouldReload: ->
    getSetting("reload") isnt "false"

  setupReloading: (force_reload_now=false)->
    if @shouldReload()
      if @reloadingEnabled isnt true
        @reloadingEnabled = true
        @_startReloading()
      else if force_reload_now
        @_startReloading()

  _startReloading: ->
    args = arguments

    clearTimeout @_currentTimeout if @_currentTimeout?
    delete @_currentTimeout

    @fetch
      complete: =>
        @_currentTimeout = setTimeout _.bind(args.callee, this), (10*60*1000)-1

  getBySlugTitle: (slug_title)->
    results = @filter (ch)-> ch.get('slug_title') == slug_title
    if results.length == 1 then results[0] else `undefined`

  orderByAuthority: ->
    @comparator = (channel) ->
      -parseFloat(channel.get("created_by_authority"))
    @sort()

  orderedByAuthority: ->
    topchannels = new ChannelList(@models)
    topchannels.orderByAuthority()

    topchannels

  channelArrayForIds: (ids) ->
    array = []
    @each (ch) ->
      if ch.id in ids
        array.push ch.clone()
    array

{'fraction_non_alphanumeric': 0.10401370533529124, 'fraction_numerical': 0.005873715124816446, 'mean_word_length': 3.4912087912087912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 36, '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': '6262166', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1195, 'n_words': 290}