diff --git a/app/models/research/hal/publication.rb b/app/models/research/hal/publication.rb index 25786b90034b52ae782908ad28fe4035078466c0..d400e147d6e3d0b138dace2bbc4a1f3041843914 100644 --- a/app/models/research/hal/publication.rb +++ b/app/models/research/hal/publication.rb @@ -60,7 +60,9 @@ class Research::Hal::Publication < ApplicationRecord 'abstract_s', 'openAccess_bool', 'journalTitle_s', - 'authLastNameFirstName_s', + 'authFullName_s', + 'authLastName_s', + 'authFirstName_s', 'files_s' # '*', ] @@ -87,7 +89,14 @@ class Research::Hal::Publication < ApplicationRecord publication.open_access = doc.attributes['openAccess_bool'] publication.journal_title = doc.attributes['journalTitle_s'] publication.file = doc.attributes['files_s']&.first - publication.authors_list = doc.attributes['authLastNameFirstName_s'].join(', ') + publication.authors_list = doc.attributes['authFullName_s'].join(', ') + publication.authors_citeproc = [] + doc.attributes['authLastName_s'].each_with_index do |last_name, index| + publication.authors_citeproc << { + "family" => last_name, + "given" => doc.attributes['authFirstName_s'][index] + } + end publication.save publication end @@ -117,9 +126,7 @@ class Research::Hal::Publication < ApplicationRecord def to_citeproc(website: nil) { "title" => title, - "author" => authors.map { |author| - { "family" => author.last_name, "given" => author.first_name } - }, + "author" => authors_citeproc, "URL" => hal_url, "container-title" => journal_title, "pdf" => file, diff --git a/db/migrate/20230711073707_add_authors_citeproc_to_research_hal_publications.rb b/db/migrate/20230711073707_add_authors_citeproc_to_research_hal_publications.rb new file mode 100644 index 0000000000000000000000000000000000000000..ed3c28160698aabb6ef845c3d60619e8d3ce15cb --- /dev/null +++ b/db/migrate/20230711073707_add_authors_citeproc_to_research_hal_publications.rb @@ -0,0 +1,5 @@ +class AddAuthorsCiteprocToResearchHalPublications < ActiveRecord::Migration[7.0] + def change + add_column :research_hal_publications, :authors_citeproc, :json + end +end diff --git a/db/schema.rb b/db/schema.rb index 21688fd27c6ee5dfb04ac16cbab44daacc1911a0..8d846ab196a019d264f4f88bf32f1f4b5af3465a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_07_11_071413) do +ActiveRecord::Schema[7.0].define(version: 2023_07_11_073707) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -744,6 +744,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_07_11_071413) do t.string "journal_title" t.text "file" t.text "authors_list" + t.json "authors_citeproc" t.index ["docid"], name: "index_research_hal_publications_on_docid" end