<commit_before>class NavigationAppsLink extends KDCustomHTMLView

  constructor:(options = {}, data)->
    options.tagName  = "a"
    options.cssClass = "title"

    super options, data

    @isFetchedAgain = no
    @counter        = 0

    @count = new KDCustomHTMLView
      tagName   : "span"
      cssClass  : "icon-top-badge"
      partial   : ""

    @count.hide()

    @icon  = new KDCustomHTMLView
      tagName   : "span"
      cssClass  : "main-nav-icon #{__utils.slugify @getData().title}"

    @getUpdateRequiredAppsCount()

    @on "AnAppHasBeenUpdated", =>
      return if @counter is 0
      @counter--
      return @count.hide() if @counter is 0
      @count.updatePartial @counter

  getUpdateRequiredAppsCount: ->
    appsController = @getSingleton "kodingAppsController"
    appsController.fetchApps (err, apps) =>
      {publishedApps} = appsController
      # just a fallback for any race condition, however not think so required
      if not publishedApps and not isFetchedAgain
        return @utils.wait 1500, =>
          @getUpdateRequiredAppsCount()
          @isFetchedAgain = yes

      for name, jApp of publishedApps when apps[name]
        @counter++ if appsController.isAppUpdateAvailable name, apps[name].version

      if @counter > 0
        @count.updatePartial @counter
        @count.show()

  viewAppended:->
    @setTemplate @pistachio()
    @template.update()

  pistachio: ->
    """
      {{> @count}} {{> @icon}} #{@getData().title}
    """
<commit_msg>app-updates: Routed to updates page when clicked to update counter.<commit_after>class NavigationAppsLink extends KDCustomHTMLView

  constructor:(options = {}, data)->
    options.tagName  = "a"
    options.cssClass = "title"

    super options, data

    @isFetchedAgain = no
    @counter        = 0

    @count = new KDCustomHTMLView
      tagName   : "span"
      cssClass  : "icon-top-badge"
      partial   : ""
      click     : (e) =>
        e.preventDefault()
        e.stopPropagation()
        @getSingleton("router").handleRoute "/Apps?filter=updates"

    @count.hide()

    @icon  = new KDCustomHTMLView
      tagName   : "span"
      cssClass  : "main-nav-icon #{__utils.slugify @getData().title}"

    @getUpdateRequiredAppsCount()

    @on "AnAppHasBeenUpdated", =>
      return if @counter is 0
      @counter--
      return @count.hide() if @counter is 0
      @count.updatePartial @counter

  getUpdateRequiredAppsCount: ->
    appsController = @getSingleton "kodingAppsController"
    appsController.fetchApps (err, apps) =>
      {publishedApps} = appsController
      # just a fallback for any race condition, however not think so required
      if not publishedApps and not isFetchedAgain
        return @utils.wait 1500, =>
          @getUpdateRequiredAppsCount()
          @isFetchedAgain = yes

      for name, jApp of publishedApps when apps[name]
        @counter++ if appsController.isAppUpdateAvailable name, apps[name].version

      if @counter > 0
        @count.updatePartial @counter
        @count.show()

  viewAppended:->
    @setTemplate @pistachio()
    @template.update()

  pistachio: ->
    """
      {{> @count}} {{> @icon}} #{@getData().title}
    """

{'fraction_non_alphanumeric': 0.11291836096340319, 'fraction_numerical': 0.005004691898654989, 'mean_word_length': 2.6590389016018308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, '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': '5526484', 'n_tokens_mistral': 1005, 'n_tokens_neox': 961, 'n_words': 237}