<commit_before>class Activity < ApplicationRecord
  include Rails.application.routes.url_helpers
  belongs_to :user
  belongs_to :ethtransaction
  belongs_to :item, polymorphic: true
  belongs_to :extra, polymorphic: true
  belongs_to :onetimer
  has_one :instances_user
  validates_presence_of :item_id, :item_type
  
  scope :by_user, ->(user_id) { where(user_id: user_id) }
  
  def linked_name

    case item.class.to_s
    when 'Pledge'
      "<a href='/proposals/#{item.item.id}'>#{item.item.name}</a>"
    when 'Proposal'
      "<a href='/proposals/#{item.id}'>#{item.name}</a>"
    when 'NilClass'
      if item_type == 'Nfc'
        'erased an ID card'
      else
        item_type.constantize.with_deleted.find(item_id).name
      end
    when 'Roombooking' 
      "<a href='/roombookings/'>#{item.day.strftime('%-d %B %Y')}</a> " + extra_info.to_s || ''
    when 'User'
      if value
        "#{item.display_name}  <br /><small>#{extra_info}</small>"
      elsif extra
        "<a href='/users/" + item.slug + "'>" + item.display_name + "</a> #{extra_info} <a href='/" + extra.class.table_name + "/#{extra.id.to_s}'>" + extra.name + "</a>"<commit_msg>activity feed now explains credits'<commit_after>class Activity < ApplicationRecord
  include Rails.application.routes.url_helpers
  belongs_to :user
  belongs_to :ethtransaction
  belongs_to :item, polymorphic: true
  belongs_to :extra, polymorphic: true
  belongs_to :onetimer
  has_one :instances_user
  validates_presence_of :item_id, :item_type
  
  scope :by_user, ->(user_id) { where(user_id: user_id) }
  
  def linked_name

    case item.class.to_s
    when 'Credit'
      item.name
    when 'Pledge'
      "<a href='/proposals/#{item.item.id}'>#{item.item.name}</a>"
    when 'Proposal'
      "<a href='/proposals/#{item.id}'>#{item.name}</a>"
    when 'NilClass'
      if item_type == 'Nfc'
        'erased an ID card'
      else
        item_type.constantize.with_deleted.find(item_id).name
      end
    when 'Roombooking' 
      "<a href='/roombookings/'>#{item.day.strftime('%-d %B %Y')}</a> " + extra_info.to_s || ''
    when 'User'
      if value
        "#{item.display_name}  <br /><small>#{extra_info}</small>"
      elsif extra
        "<a href='/users/" + item.slug + "'>" + item.display_name + "</a> #{extra_info} <a href='/" + extra.class.table_name + "/#{extra.id.to_s}'>" + extra.name + "</a>"
{'fraction_non_alphanumeric': 0.16624685138539042, 'fraction_numerical': 0.0, 'mean_word_length': 3.18804920913884, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '198818', 'n_tokens_mistral': 878, 'n_tokens_neox': 890, 'n_words': 168}