diff --git a/app/assets/images/admin/research/hal-thumb.jpg b/app/assets/images/admin/research/hal-thumb.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ae6b5571f55a41234326a88abf292a4ad7bc11e2 Binary files /dev/null and b/app/assets/images/admin/research/hal-thumb.jpg differ diff --git a/app/assets/images/admin/research/hal.jpg b/app/assets/images/admin/research/hal.jpg new file mode 100644 index 0000000000000000000000000000000000000000..99ad60212f074a7657ec8b67c06af4def8efa318 Binary files /dev/null and b/app/assets/images/admin/research/hal.jpg differ diff --git a/app/controllers/admin/research/hal/application_controller.rb b/app/controllers/admin/research/hal/application_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..0f93467570bc211f5c0cb366a72188761a37483a --- /dev/null +++ b/app/controllers/admin/research/hal/application_controller.rb @@ -0,0 +1,10 @@ +class Admin::Research::Hal::ApplicationController < Admin::Research::ApplicationController + + protected + + def breadcrumb + super + add_breadcrumb Research::Hal.model_name.human, admin_research_hal_root_path + end + +end \ No newline at end of file diff --git a/app/controllers/admin/research/hal/authors_controller.rb b/app/controllers/admin/research/hal/authors_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..762bc7e465466355851c0f9b7f94a848c0f366ae --- /dev/null +++ b/app/controllers/admin/research/hal/authors_controller.rb @@ -0,0 +1,46 @@ +class Admin::Research::Hal::AuthorsController < Admin::Research::Hal::ApplicationController + before_action :load_author, except: :index + before_action :load_researcher, only: [:connect_researcher, :disconnect_researcher] + + def index + @authors = Research::Hal::Author.ordered.page(params[:page]) + breadcrumb + end + + def show + breadcrumb + end + + def connect_researcher + @author.connect_researcher @researcher + redirect_back(fallback_location: admin_research_researcher_path(@researcher)) + end + + def disconnect_researcher + @author.disconnect_researcher @researcher + redirect_back(fallback_location: admin_research_researcher_path(@researcher)) + end + + def destroy + @author.destroy + redirect_to admin_research_hal_authors_path + end + + protected + + def load_author + @author = Research::Hal::Author.find params[:id] + end + + def load_researcher + @researcher = current_university.university_people.find params[:researcher_id] + end + + def breadcrumb + super + add_breadcrumb Research::Hal::Author.model_name.human(count: 2), + admin_research_hal_authors_path + breadcrumb_for @author + end + +end diff --git a/app/controllers/admin/research/hal/dashboard_controller.rb b/app/controllers/admin/research/hal/dashboard_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..828216c459025fecb0fece0ff9cfc6ae1a6b5a1b --- /dev/null +++ b/app/controllers/admin/research/hal/dashboard_controller.rb @@ -0,0 +1,7 @@ +class Admin::Research::Hal::DashboardController < Admin::Research::Hal::ApplicationController + def index + @namespace = Research::Hal + breadcrumb + render 'admin/dashboard/namespace' + end +end diff --git a/app/controllers/admin/research/hal/publications_controller.rb b/app/controllers/admin/research/hal/publications_controller.rb index d206f43b82ea2c088c4b84d78601c636f1f4c6ff..2f865345d72d8a6f31fca429c46e11fbce5dccc6 100644 --- a/app/controllers/admin/research/hal/publications_controller.rb +++ b/app/controllers/admin/research/hal/publications_controller.rb @@ -1,4 +1,4 @@ -class Admin::Research::Hal::PublicationsController < Admin::Research::ApplicationController +class Admin::Research::Hal::PublicationsController < Admin::Research::Hal::ApplicationController before_action :load_publication, except: :index def index diff --git a/app/controllers/admin/research/researchers_controller.rb b/app/controllers/admin/research/researchers_controller.rb index 4ccb65cd1157c54bb4ec737b284512b5d2ac12a0..0c351151827d636dd7767401390188f9701746b0 100644 --- a/app/controllers/admin/research/researchers_controller.rb +++ b/app/controllers/admin/research/researchers_controller.rb @@ -15,7 +15,7 @@ class Admin::Research::ResearchersController < Admin::Research::ApplicationContr def show @papers = @researcher.research_journal_papers.ordered.page(params[:page]) - @possible_hal_authors = @researcher.possible_hal_authors + @hal_authors_with_same_name = Research::Hal::Author.import_from_hal @researcher.to_s @papers = @researcher.research_journal_papers.ordered.page(params[:page]) breadcrumb add_breadcrumb @researcher @@ -45,7 +45,7 @@ class Admin::Research::ResearchersController < Admin::Research::ApplicationContr def breadcrumb super - add_breadcrumb t('research.researchers', count: 2), admin_research_researchers_path + add_breadcrumb University::Person::Researcher.model_name.human(count: 2), admin_research_researchers_path end end diff --git a/app/models/research/hal.rb b/app/models/research/hal.rb index 36168ff4730bebe1b7208d3168a4941ef015818c..e40cfc7365158dec600e89004f42e77d69cbefb0 100644 --- a/app/models/research/hal.rb +++ b/app/models/research/hal.rb @@ -5,4 +5,17 @@ module Research::Hal def self.table_name_prefix 'research_hal_' end + + def self.update_from_api! + Research::Hal::Author.find_each do |author| + author.import_research_hal_publications! + end + end + + def self.parts + [ + [Research::Hal::Publication, :admin_research_hal_publications_path], + [Research::Hal::Author, :admin_research_hal_authors_path], + ] + end end diff --git a/app/models/research/hal/author.rb b/app/models/research/hal/author.rb index 094f188d22b70d5e188ebfe573c08416979cb1cc..ed35b86de3452edc77b0d1b67baa8e8943525745 100644 --- a/app/models/research/hal/author.rb +++ b/app/models/research/hal/author.rb @@ -3,7 +3,7 @@ # Table name: research_hal_authors # # id :uuid not null, primary key -# doc_identifier :string +# docid :string indexed # first_name :string # form_identifier :string # full_name :string @@ -12,6 +12,71 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_research_hal_authors_on_docid (docid) +# class Research::Hal::Author < ApplicationRecord - has_and_belongs_to_many :publications + has_and_belongs_to_many :publications, + foreign_key: 'research_hal_publication_id', + association_foreign_key: 'research_hal_author_id' + has_and_belongs_to_many :university_person_researchers, + class_name: 'University::Person', + foreign_key: 'university_person_id', + association_foreign_key: 'research_hal_author_id' + alias :researchers :university_person_researchers + + scope :ordered, -> { order(:last_name, :first_name, :docid)} + + def self.import_from_hal(full_name) + authors = [] + fields = [ + 'docid', + 'form_i', + 'person_i', + 'firstName_s', + 'lastName_s', + 'fullName_s' + ] + HalOpenscience::Author.search(full_name, fields: fields).results.each do |doc| + authors << create_from(doc) + end + authors + end + + def self.create_from(doc) + author = where(docid: doc.docid).first_or_create + author.form_identifier = doc.form_i + author.person_identifier = doc&.person_i if doc.attributes.has_key?(:person_i) + author.first_name = doc.firstName_s + author.last_name = doc.lastName_s + author.full_name = doc.fullName_s + author.save + author + end + + # Direct import from HAL, does not return persisted publications + def sample_documents + HalOpenscience::Document.search("authIdFormPerson_s:#{docid}", fields: ['citationFull_s'], limit: 5) + .results + .collect(&:citationFull_s) + end + + def import_research_hal_publications! + # Do not use the API if no researcher is concerned + return if researchers.none? + Research::Hal::Publication.import_from_hal_for_author(self) + end + + def connect_researcher(researcher) + researchers << researcher + end + + def disconnect_researcher(researcher) + researchers.delete researcher + end + + def to_s + "#{full_name}" + end end diff --git a/app/models/research/hal/publication.rb b/app/models/research/hal/publication.rb index 2e82ebae65429b1dced648188395effe0323e472..1fbbbbb250611e95bde0d3fb8c5363bd62be15a2 100644 --- a/app/models/research/hal/publication.rb +++ b/app/models/research/hal/publication.rb @@ -23,9 +23,12 @@ class Research::Hal::Publication < ApplicationRecord include WithGit include WithSlug - DOI_PREFIX = 'http://dx.doi.org/'.freeze + has_and_belongs_to_many :researchers, + class_name: 'University::Person', + foreign_key: 'university_person_id', + association_foreign_key: 'research_hal_publication_id' - has_and_belongs_to_many :publications + DOI_PREFIX = 'http://dx.doi.org/'.freeze before_destroy { research_people.clear } @@ -33,9 +36,27 @@ class Research::Hal::Publication < ApplicationRecord scope :ordered, -> { order(publication_date: :desc)} + def self.import_from_hal_for_author(author) + fields = [ + 'docid', + 'title_s', + 'citationRef_s', + 'uri_s', + 'doiId_s', + 'publicationDate_tdate', + 'linkExtUrl_s', + # '*', + ] + response = HalOpenscience::Document.search "authIdForm_i:#{author.form_identifier}", fields: fields, limit: 1000 + response.results.each do |doc| + publication = Research::Hal::Publication.create_from doc + author.publications << publication unless publication.in?(author.publications) + end + end + def self.create_from(doc) publication = where(docid: doc.docid).first_or_create - puts "pub-- #{where(docid: doc.docid).count}" + puts "HAL sync publication #{doc.docid}" publication.title = Osuny::Sanitizer.sanitize doc.title_s.first, 'string' publication.ref = doc.attributes['citationRef_s'] publication.hal_url = doc.attributes['uri_s'] @@ -46,13 +67,6 @@ class Research::Hal::Publication < ApplicationRecord publication end - def self.update_from_hal - University::Person::Researcher.with_hal_identifier.find_each do |researcher| - # puts "Loading publications for #{researcher} (#{researcher.university})" - researcher.import_research_hal_publications! - end - end - def template_static "admin/research/publications/static" end diff --git a/app/models/university/person/with_research.rb b/app/models/university/person/with_research.rb index ade03dda8fce8c4248df198f7305e75e1854f5b6..a2eb612027119deaf96ba10df9b6d5f18d8000d4 100644 --- a/app/models/university/person/with_research.rb +++ b/app/models/university/person/with_research.rb @@ -2,17 +2,26 @@ module University::Person::WithResearch extend ActiveSupport::Concern included do + has_and_belongs_to_many :research_hal_authors, + class_name: 'Research::Hal::Author', + foreign_key: 'research_hal_author_id', + association_foreign_key: 'university_person_id' + alias :hal_authors :research_hal_authors + has_and_belongs_to_many :research_hal_publications, class_name: 'Research::Hal::Publication', foreign_key: 'research_publication_id', association_foreign_key: 'university_person_id' - alias :publications :research_hal_publications alias :hal_publications :research_hal_publications + alias :publications :research_hal_publications scope :with_hal_identifier, -> { where.not(hal_form_identifier: [nil,'']) } end def import_research_hal_publications! + hal_authors.each do |author| + author.import_research_hal_publications! + end response = HalOpenscience::Document.search "authIdForm_i:#{hal_form_identifier}", fields: ["*"], limit: 1000 @@ -23,8 +32,4 @@ module University::Person::WithResearch end handle_asynchronously :import_research_hal_publications! - def possible_hal_authors - HalOpenscience::Author.search(to_s, fields: ["*"]).results - end - end diff --git a/app/views/admin/research/hal/authors/_list.html.erb b/app/views/admin/research/hal/authors/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..a510036420558c26a08124b1717efd76bb4fbfab --- /dev/null +++ b/app/views/admin/research/hal/authors/_list.html.erb @@ -0,0 +1,22 @@ +<div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Research::Hal::Author.human_attribute_name('full_name') %></th> + <th><%= Research::Hal::Publication.human_attribute_name('docid') %></th> + <th><%= Research::Hal::Publication.human_attribute_name('publications') %></th> + <th><%= Research::Hal::Publication.human_attribute_name('researchers') %></th> + </tr> + </thead> + <tbody> + <% authors.each do |author| %> + <tr> + <td><%= link_to author, [:admin, author] %></td> + <td><%= author.docid %></td> + <td><%= author.publications.count %></td> + <td><%= author.researchers.count %></td> + </tr> + <% end %> + </tbody> + </table> +</div> \ No newline at end of file diff --git a/app/views/admin/research/hal/authors/index.html.erb b/app/views/admin/research/hal/authors/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..5387af7e6dddf1d9d4399dcfef402102c980dba1 --- /dev/null +++ b/app/views/admin/research/hal/authors/index.html.erb @@ -0,0 +1,4 @@ +<% content_for :title, Research::Hal::Author.model_name.human(count: 2) %> +<% content_for :title_right, "#{ @authors.total_count }" %> +<%= render 'admin/research/hal/authors/list', authors: @authors %> +<%= paginate @authors, theme: 'bootstrap-5' %> diff --git a/app/views/admin/research/hal/authors/show.html.erb b/app/views/admin/research/hal/authors/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..364d41d5edae611a5b3191cdd289efe4c9cade51 --- /dev/null +++ b/app/views/admin/research/hal/authors/show.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, @author %> + +<% content_for :action_bar_left do %> + <%= destroy_link @author %> +<% end %> diff --git a/app/views/admin/research/hal/publications/_list.html.erb b/app/views/admin/research/hal/publications/_list.html.erb index 32d1cea4dca8450d068b7ebaeea8b1020ba5cd61..259490a5403921ccd9279cc12e274c3d322fea8a 100644 --- a/app/views/admin/research/hal/publications/_list.html.erb +++ b/app/views/admin/research/hal/publications/_list.html.erb @@ -4,7 +4,7 @@ <tr> <th><%= Research::Hal::Publication.human_attribute_name('title') %></th> <th><%= Research::Hal::Publication.human_attribute_name('publication_date') %></th> - <th><%= t('research.researchers', count: 2) %></th> + <th><%= University::Person::Researcher.model_name.human(count: 2) %></th> </tr> </thead> <tbody> diff --git a/app/views/admin/research/hal/publications/show.html.erb b/app/views/admin/research/hal/publications/show.html.erb index 5caee22ded8779f70204138c3dcac9e04d8c12ad..bd3db6861925f1ffd2d2b9b8e163a28616b3e288 100644 --- a/app/views/admin/research/hal/publications/show.html.erb +++ b/app/views/admin/research/hal/publications/show.html.erb @@ -23,14 +23,14 @@ </div> </div> <div class="col-lg-4"> - <% @publication.research_people.each do |person| %> - <% next if person.university != current_university %> + <% @publication.researchers.each do |researcher| %> + <% next if researcher.university != current_university %> <article class="mb-4 d-flex align-items-center position-relative"> <div style="width: 80px"> - <%= kamifusen_tag person.best_picture, width: 80, class: 'img-circle' if person.best_picture.attached? %> + <%= kamifusen_tag researcher.best_picture, width: 80, class: 'img-circle' if researcher.best_picture.attached? %> </div> <div class="ms-3"> - <%= link_to person, admin_research_researcher_path(person), class: 'stretched-link' %> + <%= link_to researcher, admin_research_researcher_path(researcher), class: 'stretched-link' %> </div> </article> <% end %> diff --git a/app/views/admin/research/researchers/index.html.erb b/app/views/admin/research/researchers/index.html.erb index d2af199c9289f4fd6d8e3bc46aff2ef7bdbffe38..39307f48b104e19eb0f646bdc986558e601a4829 100644 --- a/app/views/admin/research/researchers/index.html.erb +++ b/app/views/admin/research/researchers/index.html.erb @@ -1,4 +1,4 @@ -<% content_for :title, t('research.researchers', count: 2) %> +<% content_for :title, University::Person::Researcher.model_name.human(count: 2) %> <%= render 'filters', current_path: admin_research_researchers_path, filters: @filters if @filters.any? %> @@ -33,9 +33,4 @@ </tbody> </table> </div> - <%= paginate @researchers, theme: 'bootstrap-5' %> - -<% content_for :action_bar_right do %> - <%= link_to t('research.manage_researchers'), admin_university_people_path, class: button_classes if can?(:read, University::Person) %> -<% end %> diff --git a/app/views/admin/research/researchers/show.html.erb b/app/views/admin/research/researchers/show.html.erb index c6deccf681aee60e0b2bc1ac69e780eeda8ee26c..1a8630be86c455d16f9cb68e59cbb7957f3b893f 100644 --- a/app/views/admin/research/researchers/show.html.erb +++ b/app/views/admin/research/researchers/show.html.erb @@ -9,30 +9,30 @@ <% end %> <% end %> -<%= osuny_panel Research::Hal::Author.model_name.human(count: 2), action: @researcher.hal_publications.count do %> +<%= osuny_panel Research::Hal::Author.model_name.human(count: 2) do %> <p><%= t 'research.hal.select_identifier' %><p> <div class="table-responsive"> <table class="table"> <tbody> - <% @possible_hal_authors.each do |author| %> - <% - path = admin_research_researcher_path @researcher, - hal_doc_identifier: author.docid, - hal_form_identifier: author.attributes['form_i'], - hal_person_identifier: author.attributes['person_i'] - %> + <% @hal_authors_with_same_name.each do |author| %> <tr> <td width="300"> - Identifiant HAL : <%= author.docid %><br> - <small><%= author.fullName_s %></small> + <%= Research::Hal::Author.human_attribute_name('docid') %> : <%= author.docid %><br> + <small><%= author.full_name %></small> </td> - <td class="ps-3" width="200"><%= link_to 'Choisir cet identifiant', path, method: :put, class: 'btn btn-primary btn-sm' %><td> + <td class="ps-3" width="200"> + <% path = researcher_admin_research_hal_author_path author, researcher_id: @researcher %> + <% if author.in? @researcher.hal_authors %> + <%= link_to 'Déconnecter', path, method: :delete, class: button_classes_danger %> + <% else %> + <%= link_to 'Connecter', path, method: :post, class: button_classes %> + <% end %> + <td> <td class="ps-3"> - <% docs = HalOpenscience::Document.search "authIdFormPerson_s:#{author.docid}", fields: ["*"], limit: 5 %> <ul class="list-unstyled small"> - <% docs.results.each do |doc| %> - <li class="mb-2"><%= sanitize doc.citationFull_s %></li> - <% end unless docs.nil? %> + <% author.sample_documents.each do |doc| %> + <li class="mb-2"><%= sanitize doc %></li> + <% end %> </ul> </td> </tr> @@ -42,7 +42,7 @@ </div> <% end %> -<%= osuny_panel Research::Hal::Publication.model_name.human do %> +<%= osuny_panel Research::Hal::Publication.model_name.human(count: 2) do %> <p><%= "#{@researcher.hal_publications.count} #{Research::Hal::Publication.model_name.human(count: @researcher.hal_publications.count).downcase}" %> <div class="table-responsive"> <%= render 'admin/research/hal/publications/list', publications: @researcher.hal_publications.ordered %> diff --git a/config/locales/research/en.yml b/config/locales/research/en.yml index 0aac0744d187e6e775ef8850116cc216221408d2..e66d575718aba5bd80da0d53427b01ee70790d57 100644 --- a/config/locales/research/en.yml +++ b/config/locales/research/en.yml @@ -9,11 +9,11 @@ en: one: Researcher other: Researchers research/hal/author: - one: Author - other: Authors + one: HAL author + other: HAL authors research/hal/publication: - one: Publication - other: Publications + one: HAL publication + other: HAL publications research/journal: one: Journal other: Journals @@ -37,6 +37,7 @@ en: other: Theses attributes: research/hal/author: + docid: HAL identifier first_name: First name last_name: Last name full_name: Full name @@ -102,10 +103,6 @@ en: hal: title: HAL select_identifier: Select all the HAL authors that correspond to this researcher. Use the publications to be sure it's the same person. - manage_researchers: Manage researchers - researchers: - one: Researcher - other: Researchers simple_form: hints: research_journal_volume: diff --git a/config/locales/research/fr.yml b/config/locales/research/fr.yml index 0cde7ec468e216adadf65a3a4caca8243b6a748e..6b9872882d0ae6c8322f53d64f0cc2100ebc52b5 100644 --- a/config/locales/research/fr.yml +++ b/config/locales/research/fr.yml @@ -9,11 +9,11 @@ fr: one: Chercheur·e other: Chercheur·e·s research/hal/author: - one: Auteur·e - other: Auteur·e·s + one: Auteur·e HAL + other: Auteur·e·s HAL research/hal/publication: - one: Publication - other: Publications + one: Publication HAL + other: Publications HAL research/journal: one: Revue scientifique other: Revues scientifiques @@ -37,6 +37,7 @@ fr: other: Thèses attributes: research/hal/author: + docid: Identifiant HAL first_name: Prénom last_name: Nom full_name: Nom complet @@ -101,10 +102,6 @@ fr: source: Serge Haroche, Prix Nobel de physique 2012 hal: select_identifier: Choisissez tou·te·s les auteur·e·s HAL correspondant à cette personne. Appuyez-vous sur les publications pour vérifier qu'il s'agit de la bonne personne. - manage_researchers: Gérer les chercheur·e·s - researchers: - one: Chercheur·e - other: Chercheur·e·s simple_form: hints: research_journal_volume: diff --git a/config/routes/admin/research.rb b/config/routes/admin/research.rb index 7792d706ece59750dcceba1f5cfcfc9658887153..832236f03da3a50a8a132c02dea5f618492f0b9a 100644 --- a/config/routes/admin/research.rb +++ b/config/routes/admin/research.rb @@ -3,7 +3,8 @@ namespace :research do namespace :hal do resources :authors, only: [:index, :show, :destroy] do member do - get :static + post 'researchers/:researcher_id' => 'authors#connect_researcher', as: :researcher + delete 'researchers/:researcher_id' => 'authors#disconnect_researcher' end end resources :publications, only: [:index, :show, :destroy] do @@ -11,6 +12,7 @@ namespace :research do get :static end end + root to: 'dashboard#index' end resources :journals do resources :volumes, controller: 'journals/volumes' do diff --git a/db/migrate/20230218055804_add_index_to_hal_authors.rb b/db/migrate/20230218055804_add_index_to_hal_authors.rb new file mode 100644 index 0000000000000000000000000000000000000000..f17083bd1a5400c16d6ba44051a10a67f97d6472 --- /dev/null +++ b/db/migrate/20230218055804_add_index_to_hal_authors.rb @@ -0,0 +1,6 @@ +class AddIndexToHalAuthors < ActiveRecord::Migration[7.0] + def change + rename_column :research_hal_authors, :doc_identifier, :docid + add_index :research_hal_authors, :docid + end +end diff --git a/db/migrate/20230218064046_rename_research_hal_authors_university_persons.rb b/db/migrate/20230218064046_rename_research_hal_authors_university_persons.rb new file mode 100644 index 0000000000000000000000000000000000000000..511ab5c75f712357cc121e8b0446220b772369f7 --- /dev/null +++ b/db/migrate/20230218064046_rename_research_hal_authors_university_persons.rb @@ -0,0 +1,5 @@ +class RenameResearchHalAuthorsUniversityPersons < ActiveRecord::Migration[7.0] + def change + rename_table :research_hal_authors_university_persons, :research_hal_authors_university_people + end +end diff --git a/db/migrate/20230218074127_fix_join_table_research_hal_publications_university_people.rb b/db/migrate/20230218074127_fix_join_table_research_hal_publications_university_people.rb new file mode 100644 index 0000000000000000000000000000000000000000..97172bad2779a75d082d7bc7d946f6a15db9bb53 --- /dev/null +++ b/db/migrate/20230218074127_fix_join_table_research_hal_publications_university_people.rb @@ -0,0 +1,5 @@ +class FixJoinTableResearchHalPublicationsUniversityPeople < ActiveRecord::Migration[7.0] + def change + rename_column :research_hal_publications_university_people, :research_publication_id, :research_hal_publication_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 018e3421e53c264aac19e28c8758f6377576e9fa..50d6e446f3514f52ff90060234b64932d8505235 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_02_17_205953) do +ActiveRecord::Schema[7.0].define(version: 2023_02_18_074127) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -593,7 +593,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_17_205953) do end create_table "research_hal_authors", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "doc_identifier" + t.string "docid" t.string "form_identifier" t.string "person_identifier" t.string "first_name" @@ -601,6 +601,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_17_205953) do t.string "full_name" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["docid"], name: "index_research_hal_authors_on_docid" end create_table "research_hal_authors_publications", id: false, force: :cascade do |t| @@ -610,7 +611,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_17_205953) do t.index ["research_hal_publication_id", "research_hal_author_id"], name: "hal_publication_author" end - create_table "research_hal_authors_university_persons", id: false, force: :cascade do |t| + create_table "research_hal_authors_university_people", id: false, force: :cascade do |t| t.uuid "research_hal_author_id", null: false t.uuid "university_person_id", null: false t.index ["research_hal_author_id", "university_person_id"], name: "hal_author_person" @@ -633,10 +634,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_17_205953) do end create_table "research_hal_publications_university_people", id: false, force: :cascade do |t| - t.uuid "research_publication_id", null: false + t.uuid "research_hal_publication_id", null: false t.uuid "university_person_id", null: false - t.index ["research_publication_id", "university_person_id"], name: "index_publication_person" - t.index ["university_person_id", "research_publication_id"], name: "index_person_publication" + t.index ["research_hal_publication_id", "university_person_id"], name: "index_publication_person" + t.index ["university_person_id", "research_hal_publication_id"], name: "index_person_publication" end create_table "research_journal_paper_kinds", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| diff --git a/lib/tasks/auto.rake b/lib/tasks/auto.rake index 0c8b23305caf5813d3bcf4624d79f1aa47257b73..7c47ebaaa12fc4eb079fb816c30ee163858ee133 100644 --- a/lib/tasks/auto.rake +++ b/lib/tasks/auto.rake @@ -1,6 +1,6 @@ namespace :auto do desc 'Update publications from HAL for all researchers' - task update_publications_from_hal: :environment do - Research::Publication.update_from_hal + task update_hal: :environment do + Research::Hal.update_from_api! end end \ No newline at end of file diff --git a/test/fixtures/research/hal/authors.yml b/test/fixtures/research/hal/authors.yml index 29f9027fd28e33384b1cb07b8fadaab6e377ae9c..d5e90da2487fda48cdb33a12713eabbc24757041 100644 --- a/test/fixtures/research/hal/authors.yml +++ b/test/fixtures/research/hal/authors.yml @@ -3,7 +3,7 @@ # Table name: research_hal_authors # # id :uuid not null, primary key -# doc_identifier :string +# docid :string indexed # first_name :string # form_identifier :string # full_name :string @@ -12,6 +12,10 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_research_hal_authors_on_docid (docid) +# one: doc_identifier: MyString diff --git a/test/models/research/hal/author_test.rb b/test/models/research/hal/author_test.rb index bda90df48fe6211be70220edcc05ff3ee1916821..c381d6c40b55ab5edd87380e0fa1a2aee58646b4 100644 --- a/test/models/research/hal/author_test.rb +++ b/test/models/research/hal/author_test.rb @@ -3,7 +3,7 @@ # Table name: research_hal_authors # # id :uuid not null, primary key -# doc_identifier :string +# docid :string indexed # first_name :string # form_identifier :string # full_name :string @@ -12,6 +12,10 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_research_hal_authors_on_docid (docid) +# require "test_helper" class Research::Hal::AuthorTest < ActiveSupport::TestCase