<commit_before>class MessagesListItemView extends KDListItemView
  constructor:(options, data)->
    super

  partial:(data)->
    "<div>#{data.subject or '(No title)'}</div>"

class MessagesListView extends KDListView

class MessagesListController extends KDListViewController

  constructor:(options, data)->
    options.itemClass           or= InboxMessagesListItem
    options.listView            or= new MessagesListView
    options.startWithLazyLoader   = yes
    super options, data

    @getListView().on "AvatarPopupShouldBeHidden", =>
      @emit 'AvatarPopupShouldBeHidden'

  fetchMessages:(callback)->
    return callback? yes  unless KD.isLoggedIn()
    KD.getSingleton("appManager").tell 'Inbox', 'fetchMessages',
      # as          : 'recipient'
      limit       : 3
      sort        :
        timestamp : -1
    , (err, messages)=>
      @removeAllItems()
      @instantiateListItems messages

      unreadCount = 0
      for message in messages
        unreadCount++ unless message.flags_?.read

      @emit "MessageCountDidChange", unreadCount
      @hideLazyLoader()
      callback? err,messages

  fetchNotificationTeasers:(callback)->
    KD.whoami().fetchActivityTeasers? {
      targetName: $in: [
        # 'CActivity'
        'CReplieeBucketActivity'
        'CFolloweeBucketActivity'
        'CLikeeBucketActivity'
        'CGroupJoineeBucketActivity'
        'CNewMemberBucketActivity'
        'CGroupJoineeBucketActivity'
        'CGroupJoinerBucketActivity'
        'CGroupLefteeBucketActivity'
        'CGroupLefterBucketActivity'
      ]
    }, {
      limit: 8
      sort:
        timestamp: -1
    }, (err, items)=>
      if err
        warn "There was a problem fetching notifications!",err
      else
        unglanced = items.filter (item)-> item.getFlagValue('glanced') isnt yes
        @emit 'NotificationCountDidChange', unglanced.length
        callback? items
      @hideLazyLoader()

class NotificationListItem extends KDListItemView

  activityNameMap = ->
    JStatusUpdate   : "your status update."
    JCodeSnip       : "your status update."
    JAccount        : "started following you."
    JPrivateMessage : "your private message."
    JComment        : "your comment."
    JDiscussion     : "your discussion."
    JOpinion        : "your opinion."
    JReview         : "your review."
    JGroup          : "your group"

  bucketNameMap = ->
    CReplieeBucketActivity     : "comment"
    CFolloweeBucketActivity    : "follow"
    CLikeeBucketActivity       : "like"
    CGroupJoineeBucketActivity : "groupJoin"
    CGroupLefteeBucketActivity : "groupLeft"

  actionPhraseMap = ->
    comment     : "commented on"
    reply       : "replied to"
    like        : "liked"
    follow      : ""
    share       : "shared"
    commit      : "committed"
    member      : "joined"
    groupJoin   : "joined"
    groupLeft   : "left"

  constructor:(options = {}, data)->

    options.tagName        or= "li"
    options.linkGroupClass or= LinkGroup
    options.avatarClass    or= AvatarView

    super options, data

    @setClass bucketNameMap()[data.bongo_.constructorName]

    @snapshot = JSON.parse Encoder.htmlDecode data.snapshot

    # group = data.map (participant)->
    #   constructorName : participant.targetOriginName
    #   id              : participant.targetOriginId

    {group} = @snapshot

    # Cleanup my activities on my content
    myid = KD.whoami()?.getId()

    return  unless myid

    group = (member for member in group when member.id isnt myid)<commit_msg>unnecessary activity fetch retrieval is prevented for group joiners and group lefters. (resolves having lots of "a koding user started following you" notifications)<commit_after>class MessagesListItemView extends KDListItemView
  constructor:(options, data)->
    super

  partial:(data)->
    "<div>#{data.subject or '(No title)'}</div>"

class MessagesListView extends KDListView

class MessagesListController extends KDListViewController

  constructor:(options, data)->
    options.itemClass           or= InboxMessagesListItem
    options.listView            or= new MessagesListView
    options.startWithLazyLoader   = yes
    super options, data

    @getListView().on "AvatarPopupShouldBeHidden", =>
      @emit 'AvatarPopupShouldBeHidden'

  fetchMessages:(callback)->
    return callback? yes  unless KD.isLoggedIn()
    KD.getSingleton("appManager").tell 'Inbox', 'fetchMessages',
      # as          : 'recipient'
      limit       : 3
      sort        :
        timestamp : -1
    , (err, messages)=>
      @removeAllItems()
      @instantiateListItems messages

      unreadCount = 0
      for message in messages
        unreadCount++ unless message.flags_?.read

      @emit "MessageCountDidChange", unreadCount
      @hideLazyLoader()
      callback? err,messages

  fetchNotificationTeasers:(callback)->
    KD.whoami().fetchActivityTeasers? {
      targetName: $in: [
        # 'CActivity'
        'CReplieeBucketActivity'
        'CFolloweeBucketActivity'
        'CLikeeBucketActivity'
        'CGroupJoineeBucketActivity'
        'CNewMemberBucketActivity'
        'CGroupLefteeBucketActivity'
      ]
    }, {
      limit: 8
      sort:
        timestamp: -1
    }, (err, items)=>
      if err
        warn "There was a problem fetching notifications!",err
      else
        unglanced = items.filter (item)-> item.getFlagValue('glanced') isnt yes
        @emit 'NotificationCountDidChange', unglanced.length
        callback? items
      @hideLazyLoader()

class NotificationListItem extends KDListItemView

  activityNameMap = ->
    JStatusUpdate   : "your status update."
    JCodeSnip       : "your status update."
    JAccount        : "started following you."
    JPrivateMessage : "your private message."
    JComment        : "your comment."
    JDiscussion     : "your discussion."
    JOpinion        : "your opinion."
    JReview         : "your review."
    JGroup          : "your group"

  bucketNameMap = ->
    CReplieeBucketActivity     : "comment"
    CFolloweeBucketActivity    : "follow"
    CLikeeBucketActivity       : "like"
    CGroupJoineeBucketActivity : "groupJoin"
    CGroupLefteeBucketActivity : "groupLeft"

  actionPhraseMap = ->
    comment     : "commented on"
    reply       : "replied to"
    like        : "liked"
    follow      : ""
    share       : "shared"
    commit      : "committed"
    groupJoin   : "joined"
    groupLeft   : "left"

  constructor:(options = {}, data)->

    options.tagName        or= "li"
    options.linkGroupClass or= LinkGroup
    options.avatarClass    or= AvatarView

    super options, data

    @setClass bucketNameMap()[data.bongo_.constructorName]

    @snapshot = JSON.parse Encoder.htmlDecode data.snapshot

    # group = data.map (participant)->
    #   constructorName : participant.targetOriginName
    #   id              : participant.targetOriginId

    {group} = @snapshot

    # Cleanup my activities on my content
    myid = KD.whoami()?.getId()

    return  unless myid

    group = (member for member in group when member.id isnt myid)
{'fraction_non_alphanumeric': 0.09228164244391139, 'fraction_numerical': 0.0014110342881332016, 'mean_word_length': 2.5422288855572215, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, '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': '5514763', 'n_tokens_mistral': 2085, 'n_tokens_neox': 1984, 'n_words': 484}