<commit_before>require 'acts_as_asset'
require 'grouped_pagination'
require 'title_trimmer'
require 'libxml'

class Publication < ActiveRecord::Base
  include Seek::Rdf::RdfGeneration
  title_trimmer
  alias_attribute :description, :abstract
  #searchable must come before acts_as_asset is called
  searchable(:ignore_attribute_changes_of=>[:updated_at,:last_used_at]) do
    text :journal,:pubmed_id, :doi
    text :publication_authors do
      publication_authors.compact.map(&:first_name) + publication_authors.compact.map(&:last_name)
    end
  end if Seek::Config.solr_enabled



  acts_as_asset

  def default_policy
    policy = Policy.new(:name => "publication_policy", :sharing_scope => Policy::EVERYONE, :access_type => Policy::VISIBLE)
    #add managers (authors + contributor)
    creators.each do |author|
      policy.permissions << Permissions.create(:contributor => author, :policy => policy, :access_type => Policy::MANAGING)
    end
    #Add contributor
    c = contributor || default_contributor
    policy.permissions << Permission.create(:contributor => c.person, :policy => policy, :access_type => Policy::MANAGING) if c
    policy
  end

  validate :check_identifier_present<commit_msg>Include publication year in the search<commit_after>require 'acts_as_asset'
require 'grouped_pagination'
require 'title_trimmer'
require 'libxml'

class Publication < ActiveRecord::Base
  include Seek::Rdf::RdfGeneration
  title_trimmer
  alias_attribute :description, :abstract
  #searchable must come before acts_as_asset is called
  searchable(:ignore_attribute_changes_of=>[:updated_at,:last_used_at]) do
    text :journal,:pubmed_id, :doi, :published_date
    text :publication_authors do
      publication_authors.compact.map(&:first_name) + publication_authors.compact.map(&:last_name)
    end
  end if Seek::Config.solr_enabled



  acts_as_asset

  def default_policy
    policy = Policy.new(:name => "publication_policy", :sharing_scope => Policy::EVERYONE, :access_type => Policy::VISIBLE)
    #add managers (authors + contributor)
    creators.each do |author|
      policy.permissions << Permissions.create(:contributor => author, :policy => policy, :access_type => Policy::MANAGING)
    end
    #Add contributor
    c = contributor || default_contributor
    policy.permissions << Permission.create(:contributor => c.person, :policy => policy, :access_type => Policy::MANAGING) if c
    policy
  end

  validate :check_identifier_present
{'fraction_non_alphanumeric': 0.10325203252032521, 'fraction_numerical': 0.0, 'mean_word_length': 5.326478149100257, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5539939', 'n_tokens_mistral': 763, 'n_tokens_neox': 730, 'n_words': 167}