<commit_before>#
# Some helper tasks to manage DOI submission
#

# pull in the helpers
require_dependency 'libra2/tasks/task_helpers'
include TaskHelpers

require_dependency 'libra2/lib/serviceclient/entity_id_client'

namespace :libra2 do

  namespace :doi do

  #
  # list DOIs for all works from the specified user
  #
  desc "List DOI's for all my works; optionally provide depositor email"
  task list_doi_my_works: :environment do |t, args|

     who = ARGV[ 1 ]
     who = TaskHelpers.default_user_email if who.nil?
     task who.to_sym do ; end

     count = 0
     GenericWork.search_in_batches( {depositor: who} ) do |group|
       TaskHelpers.batched_process_solr_works( group, &method( :show_work_doi ) )
       count += group.size
     end

     puts "Listed #{count} work(s)"
  end

  #
  # get the EZID service metadata for the specified work
  #
  desc "Get EZID metadata for the specified work; must provide the work id"
  task get_ezid_metadata_by_work: :environment do |t, args|

    work_id = ARGV[ 1 ]
    if work_id.nil?
      puts "ERROR: no work id specified, aborting"
      next
    end

    task work_id.to_sym do ; end

    work = TaskHelpers.get_work_by_id( work_id )<commit_msg>Add rake task to show DOIs for all works<commit_after>#
# Some helper tasks to manage DOI submission
#

# pull in the helpers
require_dependency 'libra2/tasks/task_helpers'
include TaskHelpers

require_dependency 'libra2/lib/serviceclient/entity_id_client'

namespace :libra2 do

  namespace :doi do

  #
  # list DOIs for all works
  #
  desc "List DOI's for all works"
  task list_doi_all_works: :environment do |t, args|

     count = 0
     GenericWork.search_in_batches( {} ) do |group|
       TaskHelpers.batched_process_solr_works( group, &method( :show_work_doi ) )
       count += group.size
     end

     puts "Listed #{count} work(s)"
  end

  #
  # list DOIs for all works from the specified user
  #
  desc "List DOI's for all my works; optionally provide depositor email"
  task list_doi_my_works: :environment do |t, args|

    who = ARGV[ 1 ]
    who = TaskHelpers.default_user_email if who.nil?
    task who.to_sym do ; end

    count = 0
    GenericWork.search_in_batches( {depositor: who} ) do |group|
      TaskHelpers.batched_process_solr_works( group, &method( :show_work_doi ) )
      count += group.size
    end

    puts "Listed #{count} work(s)"
  end

  #
  # get the EZID service metadata for the specified work
  #
  desc "Get EZID metadata for the specified work; must provide the work id"
  task get_ezid_metadata_by_work: :environment do |t, args|

    work_id = ARGV[ 1 ]
    if work_id.nil?
      puts "ERROR: no work id specified, aborting"
      next
    end

    task work_id.to_sym do ; end

    work = TaskHelpers.get_work_by_id( work_id )
{'fraction_non_alphanumeric': 0.0792967348403301, 'fraction_numerical': 0.0046645138141370645, 'mean_word_length': 3.230652503793627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '795063', 'n_tokens_mistral': 971, 'n_tokens_neox': 932, 'n_words': 300}