<commit_before>class Tag
  include Mongoid::Document
  include Mongoid::Timestamps
  
  field :name
  
  embedded_in :article, :inverse_of => :tags
  
  validates_presence_of :name
  validates_length_of :name, :minimum => 2, :maximum => 50
  validates_uniqueness_of :name
  
  def self.find_by_name(name)
    self.where(:name => name).first
  end

  # return all unique tags from articles
  # OPTIMIZE
  # TODO return also occurence of tags
  def self.all
    Article.only(:tags).all.map(&:tags).flatten.uniq
  end
  
end<commit_msg>update Tag model: remove Article->Tag embedding, add TODO<commit_after># this model is not used at the moment
# TODO either remove Tag model or refactor it into relation to Article model
#
class Tag
  include Mongoid::Document
  include Mongoid::Timestamps
  
  field :name
    
  validates_presence_of :name
  validates_length_of :name, :minimum => 2, :maximum => 50
  validates_uniqueness_of :name
  
  def self.find_by_name(name)
    self.where(:name => name).first
  end

  # return all unique tags from articles
  # OPTIMIZE
  # TODO return also occurence of tags
  def self.all
    Article.only(:tags).all.map(&:tags).flatten.uniq
  end
  
end
{'fraction_non_alphanumeric': 0.08714043993231811, 'fraction_numerical': 0.005076142131979695, 'mean_word_length': 3.751004016064257, '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': '7273642', 'n_tokens_mistral': 404, 'n_tokens_neox': 388, 'n_words': 114}