<commit_before>class ActivityTickerBaseItem extends JView
  constructor: (options = {}, data) ->
    options.cssClass = KD.utils.curry "action", options.cssClass
    super options, data

  pistachio: -> ""

  itemLinkViewClassMap :
    JAccount           : ProfileLinkView
    JNewApp            : AppLinkView
    JTag               : TagLinkView
    JGroup             : GroupLinkView
    JNewStatusUpdate   : ActivityLinkView
    JComment           : ActivityLinkView

class ActivityTickerFollowItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    # rels are flipped here
    {source, target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor    = new ProfileLinkView null, target
    @object   = new @itemLinkViewClassMap[source.bongo_.constructorName] null, source

  pistachio: ->
    {target} = @getData()

    # if current user did the activity
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You followed {{> @object}}</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} followed {{> @object}}</div>"

class ActivityTickerLikeItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target, subject} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , source

    @actor    = new ProfileLinkView null, source
    @origin   = new ProfileLinkView null, target
    @subj     = new @itemLinkViewClassMap[subject.bongo_.constructorName] null, subject

  pistachio: ->
    {source, target, subject} = @getData()
    activity = "liked"
    # i did something
    if  source.getId() is KD.whoami().getId()
      # if user liked his/her post
      if source.getId() is target.getId() then \
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} your {{> @subj}}</div>"
      else
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} {{> @origin}}'s {{> @subj}}</div>"

    # someone did something to you
    if target.getId() is KD.whoami().getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} your {{> @subj}}</div>"

    # if user liked his/her post
    if source.getId() is target.getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} their {{> @subj}}</div>"

    # rest
    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} {{> @origin}}'s {{> @subj}}</div>"


class ActivityTickerMemberItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor    = new ProfileLinkView null, target

  pistachio: ->
    {target} = @getData()
    # if current user did the activity
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You became a member</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} became a member</div>"

class ActivityTickerAppUserItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor    = new ProfileLinkView null, target
    @object   = new AppLinkView     null, source

  pistachio: ->
    {target} = @getData()
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You installed {{> @object}}</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} installed {{> @object}}</div>"

class ActivityTickerCommentItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target, object, subject} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , source

    @actor    = new ProfileLinkView null, source
    @origin   = new ProfileLinkView null, target
    @subj     = new ActivityLinkView null, object

  pistachio: ->
    {source, target, subject} = @getData()
    activity = "commented on"
    #another copy/paste. this must be changed
    # i did something
    if  source.getId() is KD.whoami().getId()
      # if user commented his/her post
      if source.getId() is target.getId() then \
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} your {{> @subj}}</div>"
      else
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} {{> @subj}}</div>"

    # someone did something to you
    if target.getId() is KD.whoami().getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} your {{> @subj}}</div>"

    # if user commented his/her post
    if source.getId() is target.getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} their {{> @subj}}</div>"

    # rest
    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} {{> @origin}}'s {{> @subj}}</div>"

class ActivityTickerStatusUpdateItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor = new ProfileLinkView null, target
    @subj  = new ActivityLinkView null, source

  pistachio: ->
    {source, target} = @getData()
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You posted {{> @subj}}</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} posted {{> @subj}}</div>"


class ActivityTickerItem extends KDListItemView
  itemClassMap =
    "JGroup_member_JAccount"           : ActivityTickerMemberItem
    "JAccount_like_JAccount"           : ActivityTickerLikeItem
    "JTag_follower_JAccount"           : ActivityTickerFollowItem
    "JAccount_follower_JAccount"       : ActivityTickerFollowItem
    "JNewApp_user_JAccount"            : ActivityTickerAppUserItem
    "JAccount_reply_JAccount"          : ActivityTickerCommentItem
    "JNewStatusUpdate_author_JAccount" : ActivityTickerStatusUpdateItem

  constructor: (options = {}, data) ->
    options.type = "activity-ticker-item"
    super options, data

  viewAppended: -><commit_msg>activityticker : comment view added.<commit_after>class ActivityTickerBaseItem extends JView
  constructor: (options = {}, data) ->
    options.cssClass = KD.utils.curry "action", options.cssClass
    super options, data

  pistachio: -> ""

  itemLinkViewClassMap :
    JAccount           : ProfileLinkView
    JNewApp            : AppLinkView
    JTag               : TagLinkView
    JGroup             : GroupLinkView
    JNewStatusUpdate   : ActivityLinkView
    JComment           : ActivityLinkView

class ActivityTickerFollowItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    # rels are flipped here
    {source, target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor    = new ProfileLinkView null, target
    @object   = new @itemLinkViewClassMap[source.bongo_.constructorName] null, source

  pistachio: ->
    {target} = @getData()

    # if current user did the activity
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You followed {{> @object}}</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} followed {{> @object}}</div>"

class ActivityTickerLikeItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target, subject} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , source

    @actor    = new ProfileLinkView null, source
    @origin   = new ProfileLinkView null, target
    @subj     = new @itemLinkViewClassMap[subject.bongo_.constructorName] null, subject

  pistachio: ->
    {source, target, subject} = @getData()
    activity = "liked"
    # i did something
    if  source.getId() is KD.whoami().getId()
      # if user liked his/her post
      if source.getId() is target.getId() then \
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} your {{> @subj}}</div>"
      else
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} {{> @origin}}'s {{> @subj}}</div>"

    # someone did something to you
    if target.getId() is KD.whoami().getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} your {{> @subj}}</div>"

    # if user liked his/her post
    if source.getId() is target.getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} their {{> @subj}}</div>"

    # rest
    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} {{> @origin}}'s {{> @subj}}</div>"


class ActivityTickerMemberItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor    = new ProfileLinkView null, target

  pistachio: ->
    {target} = @getData()
    # if current user did the activity
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You became a member</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} became a member</div>"

class ActivityTickerAppUserItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor    = new ProfileLinkView null, target
    @object   = new AppLinkView     null, source

  pistachio: ->
    {target} = @getData()
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You installed {{> @object}}</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} installed {{> @object}}</div>"

class ActivityTickerCommentItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target, object, subject} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , source

    @actor    = new ProfileLinkView null, source
    @origin   = new ProfileLinkView null, target
    @subj     = new ActivityLinkView null, object

  pistachio: ->
    {source, target, subject} = @getData()
    activity = "commented on"
    #another copy/paste. this must be changed
    # i did something
    if  source.getId() is KD.whoami().getId()
      # if user commented his/her post
      if source.getId() is target.getId() then \
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} your {{> @subj}}</div>"
      else
        return "{{> @avatar}} <div class='text-overflow'>You #{activity} {{> @subj}}</div>"

    # someone did something to you
    if target.getId() is KD.whoami().getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} your {{> @subj}}</div>"

    # if user commented his/her post
    if source.getId() is target.getId() then \
      return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} their {{> @subj}}</div>"

    # rest
    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} #{activity} {{> @origin}}'s {{> @subj}}</div>"

class ActivityTickerStatusUpdateItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data

    {source, target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , target

    @actor = new ProfileLinkView null, target
    @subj  = new ActivityLinkView null, source

  pistachio: ->
    {source, target} = @getData()
    if target.getId() is KD.whoami().getId()
      return "{{> @avatar}} <div class='text-overflow'>You posted {{> @subj}}</div>"

    return "{{> @avatar}} <div class='text-overflow'>{{> @actor}} posted {{> @subj}}</div>"


class ActivityTickerUserCommentItem extends ActivityTickerBaseItem
  constructor: (options = {}, data) ->
    super options, data
    {@source, @target} = data

    @avatar    = new AvatarView
      size     : width: 30, height: 30
      cssClass : "avatarview"
    , @target

    @origin   = new ProfileLinkView null, @target
    @subj     = new ActivityLinkView null, @source

  pistachio: ->
    """
    {{> @avatar}}
    <div class='text-overflow'>
      #{if @target.getId() is KD.whoami().getId() then "You" else @origin } commented on {{> @subj}}
    </div>
    """


class ActivityTickerItem extends KDListItemView
  itemClassMap =
    "JGroup_member_JAccount"           : ActivityTickerMemberItem
    "JAccount_like_JAccount"           : ActivityTickerLikeItem
    "JTag_follower_JAccount"           : ActivityTickerFollowItem
    "JAccount_follower_JAccount"       : ActivityTickerFollowItem
    "JNewApp_user_JAccount"            : ActivityTickerAppUserItem
    "JAccount_reply_JAccount"          : ActivityTickerCommentItem
    "JNewStatusUpdate_author_JAccount" : ActivityTickerStatusUpdateItem

  constructor: (options = {}, data) ->
    options.type = "activity-ticker-item"
    super options, data

  viewAppended: ->
{'fraction_non_alphanumeric': 0.1455003599712023, 'fraction_numerical': 0.0037437005039596834, 'mean_word_length': 3.058136137890739, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 207, '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': '7387405', 'n_tokens_mistral': 4356, 'n_tokens_neox': 4225, 'n_words': 1133}