<commit_before>class window.ChannelView extends Backbone.Marionette.Layout
  template: 'channels/channel'

  regions:
    factList: '.js-region-fact-list'
    subChannelsRegion: '.js-region-sub-channels'
    addToChannelRegion: '.js-region-add-to-channel'
    creatorProfileRegion: ".js-region-creator-profile"

  events:
    'change .js-channel-topic-switch': 'showChosenFacts'

  onRender: ->
    @showChosenFacts()

    if @model.get('inspectable?')
      @subChannelsRegion.show new SubchannelsView
        collection: @model.subchannels()
        model: @model

    if @model.get('followable?')
      @addToChannelRegion.show new FollowChannelButtonView(model: @model)

    @creatorProfileRegion.show new UserWithAuthorityBox
      model: @model.user(),
      authority: @model.get('created_by_authority')

  showChosenFacts: ->
    choice = @$('.js-channel-topic-switch').val()
    if choice == 'topic'
      @showFacts @topicFacts()
      @$('.js-region-sub-channels').hide()
    else
      @showFacts @channelFacts()
      @$('.js-region-sub-channels').show()


  showFacts: (facts) ->
    @factList.show new FactsView
      model: @model
      collection: facts

  channelFacts: -> new ChannelFacts([], channel: @model)
  topicFacts: -> @model.topic().facts()<commit_msg>Added mixpanel tracking to topics<commit_after>class window.ChannelView extends Backbone.Marionette.Layout
  template: 'channels/channel'

  regions:
    factList: '.js-region-fact-list'
    subChannelsRegion: '.js-region-sub-channels'
    addToChannelRegion: '.js-region-add-to-channel'
    creatorProfileRegion: ".js-region-creator-profile"

  events:
    'change .js-channel-topic-switch': 'showChosenFacts'

  onRender: ->
    @showChosenFacts()

    if @model.get('inspectable?')
      @subChannelsRegion.show new SubchannelsView
        collection: @model.subchannels()
        model: @model

    if @model.get('followable?')
      @addToChannelRegion.show new FollowChannelButtonView(model: @model)

    @creatorProfileRegion.show new UserWithAuthorityBox
      model: @model.user(),
      authority: @model.get('created_by_authority')

  showChosenFacts: ->
    choice = @$('.js-channel-topic-switch').val()
    if choice == 'topic'
      @showFacts @topicFacts()
      @$('.js-region-sub-channels').hide()
      mp_track "Topic: World view"
    else
      @showFacts @channelFacts()
      @$('.js-region-sub-channels').show()
      mp_track "Topic: People I follow"

  showFacts: (facts) ->
    @factList.show new FactsView
      model: @model
      collection: facts

  channelFacts: -> new ChannelFacts([], channel: @model)
  topicFacts: -> @model.topic().facts()
{'fraction_non_alphanumeric': 0.14167294649585532, 'fraction_numerical': 0.0, 'mean_word_length': 3.4176372712146423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4218656', 'n_tokens_mistral': 862, 'n_tokens_neox': 840, 'n_words': 156}