<commit_before>- attributes = item.fetch("attributes", {})
- type = attributes.fetch("resource-type-id", nil)
- includes = @works.present? ? @works[:included] : @work[:included]
- work_types = includes.select { |item| item["type"] == "work-types" }
- sources = @works.present? ? @works[:meta].fetch("sources", []) : []
- new_params = params[:model] == "works" && params["id"] == attributes.fetch("doi", nil) ? params.merge(external_link: true) : params
- title = attributes["title"].to_s.gsub(/"/, '\"')
- views =  metrics.to_h.fetch("unique-dataset-investigations-regular",0) 
- total_views =  metrics.to_h.fetch("total-dataset-investigations-regular",0) 
- downloads =   metrics.to_h.fetch("unique-dataset-requests-regular",0) 
- total_downloads =  metrics.to_h.fetch("total-dataset-requests-regular",0) 
- resolutions =  metrics.to_h.fetch("unique-resolutions-regular",0).to_i + metrics.to_h.fetch("unique-resolutions-machine","--").to_i
- citations = filter_relation_types metrics
- if @work.present? && chart_data?(chart, "unique-dataset-investigations-regular") 
  - gon.chart_views = process_chart_data chart, ["unique-dataset-investigations-regular"], attributes.fetch("published", "").to_i
  - gon.yop = attributes.fetch("published", "").to_i
- if @work.present? && chart_data?(chart, "unique-dataset-requests-regular") 
  - gon.chart_downloads = process_chart_data chart, ["unique-dataset-requests-regular"], attributes.fetch("published", "").to_i
  - gon.yop = attributes.fetch("published", "").to_i
- if @work.present? && citations.positive?
  - gon.chart_citations = citation_chart["years"]
  - gon.yop = attributes.fetch("published", "").to_i


.panel.panel-default
  .panel-body
    %h3.work
      %a{:id => "title-link", :href => works_action(item, new_params), :title => "Go to landing page"}
        = attributes["title"]
    - if attributes["author"].present?
      = author_format(attributes["author"])
    .metadata
      = metadata_format(attributes, work_types: work_types)
    - if attributes["description"].present?
      .description
        = description_format(attributes["description"])
    - if attributes["license"].present?
      .license
        %a{:href => attributes["license"]}
          = license_img(attributes["license"])

  .panel-footer
    - if views.positive?
      %a.usage-counts.usage-views{:href => "#{works_action(item,{})+'#views-tab'}"}
        .fa.fa-eye
        = "#{views} Views"
    - if downloads.positive?
      %a.usage-counts.usage-downloads{:href => "#{works_action(item,{})+'#downloads-tab'}"}
        .fa.fa-download            
        = "#{downloads} Downloads"
        -# %span.usage-counts
        -#   .fa.fa-bolt
        -#   = "#{resolutions} Resolutions"
    - if citations.positive?
      %a.usage-counts.citations{:href => "#{works_action(item,{})+'#citations-tab'}"}
        .fa.fa-quote-right
        = "#{citations} Citations"
    - unless (views.positive? || downloads.positive? || @work.present?)
      %span.usage-info
        .fa.fa-info-circle 
      %a
        = "This data center is not currently reporting usage information."

  - if @work.present? && @work.fetch(:data, {}).fetch("attributes", {}).fetch("related-identifiers", nil).present? && @work.fetch(:data, {}).fetch("id", "work") != item["id"]
    .panel-footer
      = relation_type_title(@work.fetch(:data, {}).fetch("attributes", {}).fetch("related-identifiers"), item["id"]) + " " + @work.fetch(:data, {}).fetch("id", nil)

  .panel-footer.item-links
    %a{:id => "doi-link", :href => item["id"], :title => "Go to landing page"}
      %i.fa.fa-external-link
      = item["id"]
    - if attributes["doi"].present?
      %a.cite-link.nowrap{href: '#', onclick: "showCiteBox(\"#{attributes["doi"]}\", \"#{title}\"); return false;"}
        %i.fa.fa-quote-left
        Cite

    - if user_signed_in? && attributes["member-id"].to_i == 0
      = haml :'works/claim', locals: { item: item }

- if @work.present? 
  - if (metrics?(metrics))
    = haml :'works/visualisation', locals: { attributes: attributes, views: views, downloads: downloads, citations: citations, total_views: total_views, total_downloads: total_downloads}
  - else
    .panel.panel-default
      .panel-body
        = "This data center is not currently reporting usage information. For information on how your repository can submit usage information, please see"
        %a{href: 'https://support.datacite.org/docs/usage-reports-api-guide'}
          our Documentation.

- if @work.present? 
  - if citations.positive?
    = haml :'citations/list', locals: { attributes: attributes, citations: citations}<commit_msg>addressing change of the API when moving from lagottino<commit_after>- attributes = item.fetch("attributes", {})
- type = attributes.fetch("resource-type-id", nil)
- includes = @works.present? ? @works[:included] : @work[:included]
- work_types = includes.select { |item| item["type"] == "work-types" }
- sources = @works.present? ? @works[:meta].fetch("sources", []) : []
- new_params = params[:model] == "works" && params["id"] == attributes.fetch("doi", nil) ? params.merge(external_link: true) : params
- title = attributes["title"].to_s.gsub(/"/, '\"')
- views =  metrics.to_h.fetch("unique-dataset-investigations-regular",0) 
- total_views =  metrics.to_h.fetch("total-dataset-investigations-regular",0) 
- downloads =   metrics.to_h.fetch("unique-dataset-requests-regular",0) 
- total_downloads =  metrics.to_h.fetch("total-dataset-requests-regular",0) 
- resolutions =  metrics.to_h.fetch("unique-resolutions-regular",0).to_i + metrics.to_h.fetch("unique-resolutions-machine","--").to_i
- citations = filter_relation_types metrics ###metrics.fetch("uniqueCitations",0).to_i
- if @work.present? && chart_data?(chart, "unique-dataset-investigations-regular") 
  - gon.chart_views = process_chart_data chart, ["unique-dataset-investigations-regular"], attributes.fetch("published", "").to_i
  - gon.yop = attributes.fetch("published", "").to_i
- if @work.present? && chart_data?(chart, "unique-dataset-requests-regular") 
  - gon.chart_downloads = process_chart_data chart, ["unique-dataset-requests-regular"], attributes.fetch("published", "").to_i
  - gon.yop = attributes.fetch("published", "").to_i
- if @work.present? && citations.positive?
  - gon.chart_citations = citation_chart["years"]
  - gon.yop = attributes.fetch("published", "").to_i
- if ENV['RACK_ENV'] == 'production' ### TODO: Remove soon. set temporaly to send to production 
  - citations = 0 ### TODO: Remove soon. set temporaly to send to production 


.panel.panel-default
  .panel-body
    %h3.work
      %a{:id => "title-link", :href => works_action(item, new_params), :title => "Go to landing page"}
        = attributes["title"]
    - if attributes["author"].present?
      = author_format(attributes["author"])
    .metadata
      = metadata_format(attributes, work_types: work_types)
    - if attributes["description"].present?
      .description
        = description_format(attributes["description"])
    - if attributes["license"].present?
      .license
        %a{:href => attributes["license"]}
          = license_img(attributes["license"])

  - if ((views+downloads+citations).positive?)
    .panel-footer
      - if views.positive?
        %a.usage-counts.usage-views{:href => "#{works_action(item,{})+'#views-tab'}"}
          .fa.fa-eye
          = "#{views} Views"
      - if downloads.positive?
        %a.usage-counts.usage-downloads{:href => "#{works_action(item,{})+'#downloads-tab'}"}
          .fa.fa-download            
          = "#{downloads} Downloads"
          -# %span.usage-counts
          -#   .fa.fa-bolt
          -#   = "#{resolutions} Resolutions"
      - if citations.positive?
        %a.usage-counts.citations{:href => "#{works_action(item,{})+'#citations-tab'}"}
          .fa.fa-quote-right
          = "#{citations} Citations"
      - if ((views+downloads).zero? && @work.blank?)
        %span.usage-info
          .fa.fa-info-circle 
        %a
          = "This data center is not currently reporting usage information."
  - else
    - unless (@work.present?)
      .panel-footer
        %span.usage-info
          .fa.fa-info-circle 
        %a
          = "This data center is not currently reporting usage information." 

  - if @work.present? && @work.fetch(:data, {}).fetch("attributes", {}).fetch("related-identifiers", nil).present? && @work.fetch(:data, {}).fetch("id", "work") != item["id"]
    .panel-footer
      = relation_type_title(@work.fetch(:data, {}).fetch("attributes", {}).fetch("related-identifiers"), item["id"]) + " " + @work.fetch(:data, {}).fetch("id", nil)

  .panel-footer.item-links
    %a{:id => "doi-link", :href => item["id"], :title => "Go to landing page"}
      %i.fa.fa-external-link
      = item["id"]
    - if attributes["doi"].present?
      %a.cite-link.nowrap{href: '#', onclick: "showCiteBox(\"#{attributes["doi"]}\", \"#{title}\"); return false;"}
        %i.fa.fa-quote-left
        Cite

    - if user_signed_in? && attributes["member-id"].to_i == 0
      = haml :'works/claim', locals: { item: item }

- if @work.present? 
  - if ((views+downloads+citations).positive?)
    = haml :'works/visualisation', locals: { attributes: attributes, views: views, downloads: downloads, citations: citations, total_views: total_views, total_downloads: total_downloads}
  - if ((views+downloads).zero?)
    .panel.panel-default
      .panel-body
        = "This data center is not currently reporting usage information. For information on how your repository can submit usage information, please see"
        %a{href: 'https://support.datacite.org/docs/views-and-downloads'}
          our Documentation.

- if @work.present? 
  - if citations.positive?
    = haml :'citations/list', locals: { attributes: attributes, citations: citations, summary: metrics}
{'fraction_non_alphanumeric': 0.18260339396402805, 'fraction_numerical': 0.001625851031399248, 'mean_word_length': 3.5022872827081426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '316356', 'n_tokens_mistral': 3185, 'n_tokens_neox': 3068, 'n_words': 565}