Class: Kishu::ResolutionEvent
- Inherits:
-
Object
- Object
- Kishu::ResolutionEvent
- Includes:
- Utils
- Defined in:
- lib/kishu/resolution_event.rb
Instance Method Summary collapse
-
#initialize(event, options = {}) ⇒ ResolutionEvent
constructor
A new instance of ResolutionEvent.
- #wrap_event ⇒ Object
Methods included from Utils
#checksum, #clean_tmp, #encoded, #encoded_file, #format_instance, #generate_header_footer, #get_authors, #get_metadata, #merged_file
Constructor Details
#initialize(event, options = {}) ⇒ ResolutionEvent
Returns a new instance of ResolutionEvent.
15 16 17 18 19 |
# File 'lib/kishu/resolution_event.rb', line 15 def initialize(event, ={}) @event = event @logger = Logger.new(STDOUT) @period = [:period] end |
Instance Method Details
#wrap_event ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kishu/resolution_event.rb', line 21 def wrap_event # puts "------------------ \n" totale = @event.dig("totale").fetch("buckets", []) # puts @event.dig("unique").fetch("buckets", nil) unique = @event.dig("unique").fetch("buckets", []) # puts unique[1].dig('key') unique_regular = unique.find_all {|access_method| access_method.fetch('key',"").match('regular') } unique_machine = unique.find_all {|access_method| access_method.fetch('key',"").match('machine') } total_regular = totale.find_all {|access_method| access_method.fetch('key',"").match('regular') } total_machine = totale.find_all {|access_method| access_method.fetch('key',"").match('machine') } dataset = { doi: @event.dig("key","doi"), unique_counts_regular: unique_regular.empty? ? 0 : unique_regular.size, unique_counts_machine: unique_machine.empty? ? 0 : unique_machine.size, total_counts_regular: total_regular.empty? ? 0 : total_regular.dig(0,"doc_count"), total_counts_machine: total_machine.empty? ? 0 : total_machine.dig(0,"doc_count") } @doi = dataset.fetch(:doi,nil) instances =[ { "count" => dataset.fetch(:total_counts_regular), "access-method" => "regular", "metric-type" => "total-resolutions" }, { "count" => dataset.fetch(:unique_counts_regular), "access-method" => "regular", "metric-type" => "unique-resolutions" }, { "count" => dataset.fetch(:unique_counts_machine), "access-method" => "machine", "metric-type" => "unique-resolutions" }, { "count" => dataset.fetch(:total_counts_machine), "access-method" => "machine", "metric-type" => "total-resolutions" }, ] instances.delete_if {|instance| instance.dig("count") < 1} instanced = { "dataset-id" => [{"type" => "doi", "value"=> dataset.fetch(:doi,nil)}], "performance" => [{ "period"=> @period, "instance"=> instances }] } instanced end |