<commit_before>module StashDatacite
  class Creator < ActiveRecord::Base
    self.table_name = 'dcs_creators'
    belongs_to :resource, class_name: StashDatacite.resource_class.to_s
    belongs_to :name_identifier
    belongs_to :affliation

    before_save :strip_whitespace

    scope :filled, -> { joins(:affliation).
        where("TRIM(IFNULL(creator_first_name,'')) <> '' AND TRIM(IFNULL(creator_last_name,'')) <> ''") }

    scope :names_filled, -> { where("TRIM(IFNULL(creator_first_name,'')) <> ''") }


    scope :affliation_filled, -> { joins(:affliation).
        where("TRIM(IFNULL(dcs_affliations.long_name,'')) <> ''") }

    def creator_full_name
      "#{creator_last_name}, #{creator_first_name}".strip
    end

    private
    def strip_whitespace
      self.creator_first_name = self.creator_first_name.strip unless self.creator_first_name.nil?
      self.creator_last_name = self.creator_last_name.strip unless self.creator_last_name.nil?
    end
  end
end<commit_msg>remove orphan commas from author name on review page<commit_after>module StashDatacite
  class Creator < ActiveRecord::Base
    self.table_name = 'dcs_creators'
    belongs_to :resource, class_name: StashDatacite.resource_class.to_s
    belongs_to :name_identifier
    belongs_to :affliation

    before_save :strip_whitespace

    scope :filled, -> { joins(:affliation).
        where("TRIM(IFNULL(creator_first_name,'')) <> '' AND TRIM(IFNULL(creator_last_name,'')) <> ''") }

    scope :names_filled, -> { where("TRIM(IFNULL(creator_first_name,'')) <> ''") }


    scope :affliation_filled, -> { joins(:affliation).
        where("TRIM(IFNULL(dcs_affliations.long_name,'')) <> ''") }

    def creator_full_name
      full_name = [creator_last_name, creator_first_name]
      creator_full_name = full_name.compact.split("").flatten.join(", ")
      return creator_full_name
    end

    private
    def strip_whitespace
      self.creator_first_name = self.creator_first_name.strip unless self.creator_first_name.nil?
      self.creator_last_name = self.creator_last_name.strip unless self.creator_last_name.nil?
    end
  end
end
{'fraction_non_alphanumeric': 0.12164073550212164, 'fraction_numerical': 0.0, 'mean_word_length': 4.252475247524752, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '231295', 'n_tokens_mistral': 742, 'n_tokens_neox': 720, 'n_words': 110}