<commit_before>module ActivitiesHelper

  # Given an activity, return a message for the feed for the activity's class.
  def feed_message(activity, recent = false)
    dog = activity.dog
    case activity_type(activity)
    when "BlogPost"
      post = activity.item
      blog = post.blog
      view_blog = blog_link("#{h blog.owner.name}'s blog", blog)
      if recent
        %(new blog post  #{post_link(blog, post)})
      else
        %(#{dog_link_with_image(dog)} posted
          #{post_link(blog, post)} &mdash; #{view_blog})
      end
    when "Comment"
      parent = activity.item.commentable
      parent_type = parent.class.to_s
      case parent_type
      when "BlogPost"
        post = activity.item.commentable
        blog = post.blog
        if recent
          %(made a comment to #{someones(blog.dog, dog)} blog post
            #{post_link(blog, post)})
        else
          %(#{dog_link_with_image(dog)} made a comment to
            #{someones(blog.dog, dog)} blog post
            #{post_link(blog, post)})
        end
      when "Dog", "Group"
        if recent
          %(commented on #{wall(activity)})
        else
          %(#{dog_link_with_image(activity.item.commenter)}
            commented on #{wall(activity)})
        end
      when "Event"
        event = activity.item.commentable
        commenter = activity.item.commenter
        if recent
          %(commented on event #{event_link(event.title, event)})
        else
          %(#{dog_link_with_image(commenter)} commented on 
          #{someones(event.dog, commenter)} event 
          #{event_link(event.title, event)})
        end
      end
    when "Connection"
      if activity.item.contact.owner.admin?
        if recent
          %(joined the system)
        else
          %(#{dog_link_with_image(activity.item.dog)}
            has joined the system)
        end
      else
        if recent
          %(connected with #{dog_link_with_image(activity.item.contact)})
        else
          %(#{dog_link_with_image(activity.item.dog)} and
            #{dog_link_with_image(activity.item.contact)} have connected)
        end
      end
    when "ForumPost"
      post = activity.item
      if recent
        %(new post to forum topic #{topic_link(post.topic)})
      else
        %(#{dog_link_with_image(dog)} made a post to forum topic
          #{topic_link(post.topic)})
      end
    when "Topic"
      if recent
        %(new discussion topic #{topic_link(activity.item)})
      else
        %(#{dog_link_with_image(dog)} created the new discussion topic
          #{topic_link(activity.item)})
      end
    when "Dog"
      if recent
        %(description changed)
      else
        %(#{dog_link_with_image(dog)}'s description changed)
      end
    when "Group"
      if recent
        %(new group #{group_link(activity.item)})
      else
        %(#{dog_link_with_image(dog)} created group #{group_link_with_image(activity.item)})
      end
    when "Membership"
      if recent
        %(new member in group #{group_link(activity.item.group)})
      else
        %(#{dog_link_with_image(dog)} joined group #{group_link_with_image(activity.item.group)})
      end
    when "Gallery"
      if recent
        %(new gallery #{gallery_link(activity.item)})
      else
        %(#{dog_link_with_image(dog)} added a new gallery
          #{gallery_link(activity.item)})
      end
    when "Photo"
      if recent
        %(added new #{photo_link(activity.item)}
          #{to_gallery_link(activity.item.gallery)})
      else
        %(#{dog_link_with_image(dog)} added a new
          #{photo_link(activity.item)}
          #{to_gallery_link(activity.item.gallery)})
      end
    when "Event"
      event = activity.item
      %(#{dog_link_with_image(dog)} has created a new event:
        #{event_link(event.title, event)}.)
    when "EventAttendee"
      event = activity.item.event
      %(#{dog_link_with_image(dog)} is attending
        #{someones(event.dog, dog)} event: 
        #{event_link(event.title, event)}.) 
    else
      raise "Invalid activity type #{activity_type(activity).inspect}"
    end
  end
  
  def minifeed_message(activity)
    dog = activity.dog
    case activity_type(activity)
    when "BlogPost"
      post = activity.item
      blog = post.blog
      blog_type = blog.owner.class.to_s
      case blog_type
        when 'Dog'
          description = 'new blog post'
        when 'Group'
          description = 'new group blog post'
      end
      %(#{dog_link(dog)} made a
        #{post_link(description, blog, post)})
    when "Comment"
      parent = activity.item.commentable
      parent_type = parent.class.to_s
      case parent_type
      when "BlogPost"
        post = activity.item.commentable
        blog = post.blog
        %(#{dog_link(dog)} made a comment on
          #{someones(blog.dog, dog)} 
          #{post_link("blog post", post.blog, post)})
      when "Dog", "Group"
        %(#{dog_link(activity.item.commenter)} commented on 
          #{wall(activity)}.)
      when "Event"
        event = activity.item.commentable
        %(#{dog_link(activity.item.commenter)} commented on 
          #{someones(event.dog, activity.item.commenter)} #{event_link("event", event)}.)
      end
    when "Connection"
      if activity.item.contact.owner.admin?
        %(#{dog_link(dog)} has joined the system)
      else
        %(#{dog_link(dog)} and
          #{dog_link(activity.item.contact)} have connected)
      end
    when "ForumPost"
      topic = activity.item.topic
      %(#{dog_link(dog)} made a
        #{topic_link("forum post", topic)})
    when "Topic"
      %(#{dog_link(dog)} created a 
        #{topic_link("new discussion topic", activity.item)})
    when "Dog"
      %(#{dog_link(dog)}'s description changed)
    when "Group"
      %(#{dog_link(dog)} created group #{group_link(activity.item)}) 
    when "Membership"
      %(#{dog_link(dog)} joined group #{group_link(activity.item.group)})
    when "Gallery"
      %(#{dog_link(dog)} added a new gallery
        #{gallery_link(activity.item)})<commit_msg>remove the dog joined the system activity item from helper<commit_after>module ActivitiesHelper

  # Given an activity, return a message for the feed for the activity's class.
  def feed_message(activity, recent = false)
    dog = activity.dog
    case activity_type(activity)
    when "BlogPost"
      post = activity.item
      blog = post.blog
      view_blog = blog_link("#{h blog.owner.name}'s blog", blog)
      if recent
        %(new blog post  #{post_link(blog, post)})
      else
        %(#{dog_link_with_image(dog)} posted
          #{post_link(blog, post)} &mdash; #{view_blog})
      end
    when "Comment"
      parent = activity.item.commentable
      parent_type = parent.class.to_s
      case parent_type
      when "BlogPost"
        post = activity.item.commentable
        blog = post.blog
        if recent
          %(made a comment to #{someones(blog.dog, dog)} blog post
            #{post_link(blog, post)})
        else
          %(#{dog_link_with_image(dog)} made a comment to
            #{someones(blog.dog, dog)} blog post
            #{post_link(blog, post)})
        end
      when "Dog", "Group"
        if recent
          %(commented on #{wall(activity)})
        else
          %(#{dog_link_with_image(activity.item.commenter)}
            commented on #{wall(activity)})
        end
      when "Event"
        event = activity.item.commentable
        commenter = activity.item.commenter
        if recent
          %(commented on event #{event_link(event.title, event)})
        else
          %(#{dog_link_with_image(commenter)} commented on 
          #{someones(event.dog, commenter)} event 
          #{event_link(event.title, event)})
        end
      end
    when "Connection"
      if recent
        %(connected with #{dog_link_with_image(activity.item.contact)})
      else
        %(#{dog_link_with_image(activity.item.dog)} and
          #{dog_link_with_image(activity.item.contact)} have connected)
      end
    when "ForumPost"
      post = activity.item
      if recent
        %(new post to forum topic #{topic_link(post.topic)})
      else
        %(#{dog_link_with_image(dog)} made a post to forum topic
          #{topic_link(post.topic)})
      end
    when "Topic"
      if recent
        %(new discussion topic #{topic_link(activity.item)})
      else
        %(#{dog_link_with_image(dog)} created the new discussion topic
          #{topic_link(activity.item)})
      end
    when "Dog"
      if recent
        %(description changed)
      else
        %(#{dog_link_with_image(dog)}'s description changed)
      end
    when "Group"
      if recent
        %(new group #{group_link(activity.item)})
      else
        %(#{dog_link_with_image(dog)} created group #{group_link_with_image(activity.item)})
      end
    when "Membership"
      if recent
        %(new member in group #{group_link(activity.item.group)})
      else
        %(#{dog_link_with_image(dog)} joined group #{group_link_with_image(activity.item.group)})
      end
    when "Gallery"
      if recent
        %(new gallery #{gallery_link(activity.item)})
      else
        %(#{dog_link_with_image(dog)} added a new gallery
          #{gallery_link(activity.item)})
      end
    when "Photo"
      if recent
        %(added new #{photo_link(activity.item)}
          #{to_gallery_link(activity.item.gallery)})
      else
        %(#{dog_link_with_image(dog)} added a new
          #{photo_link(activity.item)}
          #{to_gallery_link(activity.item.gallery)})
      end
    when "Event"
      event = activity.item
      %(#{dog_link_with_image(dog)} has created a new event:
        #{event_link(event.title, event)}.)
    when "EventAttendee"
      event = activity.item.event
      %(#{dog_link_with_image(dog)} is attending
        #{someones(event.dog, dog)} event: 
        #{event_link(event.title, event)}.) 
    else
      raise "Invalid activity type #{activity_type(activity).inspect}"
    end
  end
  
  def minifeed_message(activity)
    dog = activity.dog
    case activity_type(activity)
    when "BlogPost"
      post = activity.item
      blog = post.blog
      blog_type = blog.owner.class.to_s
      case blog_type
        when 'Dog'
          description = 'new blog post'
        when 'Group'
          description = 'new group blog post'
      end
      %(#{dog_link(dog)} made a
        #{post_link(description, blog, post)})
    when "Comment"
      parent = activity.item.commentable
      parent_type = parent.class.to_s
      case parent_type
      when "BlogPost"
        post = activity.item.commentable
        blog = post.blog
        %(#{dog_link(dog)} made a comment on
          #{someones(blog.dog, dog)} 
          #{post_link("blog post", post.blog, post)})
      when "Dog", "Group"
        %(#{dog_link(activity.item.commenter)} commented on 
          #{wall(activity)}.)
      when "Event"
        event = activity.item.commentable
        %(#{dog_link(activity.item.commenter)} commented on 
          #{someones(event.dog, activity.item.commenter)} #{event_link("event", event)}.)
      end
    when "Connection"
      %(#{dog_link(dog)} and
        #{dog_link(activity.item.contact)} have connected)
    when "ForumPost"
      topic = activity.item.topic
      %(#{dog_link(dog)} made a
        #{topic_link("forum post", topic)})
    when "Topic"
      %(#{dog_link(dog)} created a 
        #{topic_link("new discussion topic", activity.item)})
    when "Dog"
      %(#{dog_link(dog)}'s description changed)
    when "Group"
      %(#{dog_link(dog)} created group #{group_link(activity.item)}) 
    when "Membership"
      %(#{dog_link(dog)} joined group #{group_link(activity.item.group)})
    when "Gallery"
      %(#{dog_link(dog)} added a new gallery
        #{gallery_link(activity.item)})
{'fraction_non_alphanumeric': 0.12095414699932569, 'fraction_numerical': 0.0, 'mean_word_length': 2.3526419892625037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4310136', 'n_tokens_mistral': 3641, 'n_tokens_neox': 3549, 'n_words': 857}