<commit_before>class Post 
  require 'lib/common'
  include ApplicationHelper 
  
  # XML accessors must always preceed mongo field tags

  include Mongoid::Document
  include Mongoid::Timestamps
  include ROXML
  include Diaspora::Webhooks


  belongs_to_related :person
  

  before_create :set_defaults

  after_save :send_to_view

  @@models = ["StatusMessage", "Bookmark", "Blog"]

  def self.stream
    # Need to explicitly name each inherited model for dev environment
    query = if Rails.env == "development"
        Post.criteria.all(:_type => @@models)
      else
        Post.criteria.all
      end
    query.order_by( [:created_at, :desc] )
  end

  def each
    yield self 
  end

 def self.newest(person = nil)
    return self.last if person.nil?
    self.where(:person_id => person.id).last
  end

  def self.newest_by_email(email)
    self.where(:person_id => Person.where(:email => email).first.id).last
  end


  protected

  def send_to_view
    self.reload
    WebSocket.update_clients(self)
  end

  def set_defaults
    self.person ||= User.first
  end
end
<commit_msg>RS IZ my newest fix<commit_after>class Post 
  require 'lib/common'
  include ApplicationHelper 
  
  # XML accessors must always preceed mongo field tags

  include Mongoid::Document
  include Mongoid::Timestamps
  include ROXML
  include Diaspora::Webhooks


  belongs_to_related :person
  

  before_create :set_defaults

  after_save :send_to_view

  @@models = ["StatusMessage", "Bookmark", "Blog"]

  def self.stream
    # Need to explicitly name each inherited model for dev environment
    query = if Rails.env == "development"
        Post.criteria.all(:_type => @@models)
      else
        Post.criteria.all
      end
    query.order_by( [:created_at, :desc] )
  end

  def each
    yield self 
  end

 def self.newest(person = nil)
    return self.last if person.nil?
    self.where(:person_id => person.id).last
  end

 def self.my_newest
   self.newest(User.first)
 end
  def self.newest_by_email(email)
    self.where(:person_id => Person.where(:email => email).first.id).last
  end


  protected

  def send_to_view
    self.reload
    WebSocket.update_clients(self)
  end

  def set_defaults
    self.person ||= User.first
  end
end

{'fraction_non_alphanumeric': 0.0896520963425513, 'fraction_numerical': 0.0, 'mean_word_length': 3.1155963302752294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4694477', 'n_tokens_mistral': 755, 'n_tokens_neox': 714, 'n_words': 188}