<commit_before>module Facts
  class FactBubble < Mustache::Railstache
    def self.for_fact_and_view(fact, view, channel=nil, modal=nil)
      fb = new
      fb.view = view
      fb[:channel] = channel
      fb[:fact] = fact
      fb[:modal] = modal
      return fb
    end
    
    def user_signed_in?
      self.view.user_signed_in?
    end

    def i_am_fact_owner
      (self[:fact].created_by == current_graph_user)
    end

    def editable_title_class
      (user_signed_in? and i_am_fact_owner) ? " edit " : ""
    end

    def scroll_to_link
      show_links ? link_to(pretty_url, self[:fact].site.url, :target => "_blank") : pretty_url
    end

    def link
      displaystring = h self[:fact].data.displaystring
      show_links ? link_to(displaystring, proxy_scroll_url, :target => "_blank") : displaystring
    end
  
    def last_activity
      activity = self[:fact].activities(1)[0]
      activity && link_to(activity.user.user.username, user_profile_path(activity.user.user.username), target: "_top") + " " + activity.action + " " + time_ago_in_words(activity.created_at) + " ago"
    end
    
    def fact_title
      self[:fact].data.title
    end
    
    def fact_id
      self[:fact].id
    end
    
    def fact_wheel
      Facts::FactWheel.for_fact_and_view(self[:fact], self.view)
    end

    private
      def show_links<commit_msg>also pass other parameters, and do to_hash, otherwise in ruby this does not work.<commit_after>module Facts
  class FactBubble < Mustache::Railstache
    def self.for_fact_and_view(fact, view, channel=nil, modal=nil)
      fb = new
      fb.view = view
      fb[:channel] = channel
      fb[:fact] = fact
      fb[:modal] = modal
      return fb
    end
    
    def user_signed_in?
      self.view.user_signed_in?
    end

    def i_am_fact_owner
      (self[:fact].created_by == current_graph_user)
    end

    def editable_title_class
      (user_signed_in? and i_am_fact_owner) ? " edit " : ""
    end

    def scroll_to_link
      show_links ? link_to(pretty_url, self[:fact].site.url, :target => "_blank") : pretty_url
    end

    def link
      displaystring = h self[:fact].data.displaystring
      show_links ? link_to(displaystring, proxy_scroll_url, :target => "_blank") : displaystring
    end
  
    def last_activity
      activity = self[:fact].activities(1)[0]
      activity && link_to(activity.user.user.username, user_profile_path(activity.user.user.username), target: "_top") + " " + activity.action + " " + time_ago_in_words(activity.created_at) + " ago"
    end
    
    def fact_title
      self[:fact].data.title
    end
    
    def fact_id
      self[:fact].id
    end
    
    def fact_wheel
      Facts::FactWheel.for_fact_and_view(self[:fact], self.view, self[:channel],self[:modal]).to_hash
    end

    private
      def show_links
{'fraction_non_alphanumeric': 0.10556145944031173, 'fraction_numerical': 0.0014169323414806943, 'mean_word_length': 2.790604026845638, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7469554', 'n_tokens_mistral': 956, 'n_tokens_neox': 924, 'n_words': 191}