Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Involved authorities #345

Merged
merged 8 commits into from
May 15, 2024
Merged

Involved authorities #345

merged 8 commits into from
May 15, 2024

Conversation

damisul
Copy link
Collaborator

@damisul damisul commented May 14, 2024

This PR introduces new InvolvedAuthorities table to replace Creations and Realizers table.

It does not intoduces Authorities table yet, so InvolvedAuthority record can only refer to person.
Also I did not used polymorphic relation for item and added expression_id and work_id as separate columns instead.
I believe it is better from performance point of view and more SQL-friendly approach.

Also this PR contains following changes not directly related to InvolvedAuthorities:

  • It fixes HtmlFile.create_WEM_new method to work with new intellectual_property field (see logic for getting Expression.intellectual_property value from author and translator, I did my best from my understanding of logic)
  • It removes bunch of unused methods and scopes from Person and ApplicationController classes

…et_popular_translators, Person.get_popular_xlat_authors, Person.get_popular_xlat_authors_by_genre, ApplicationController.cached_popular_authors_by_genre, ApplicationController.popups_by_genre, ApplicationController.count_authors_by_genre
Removed unused method Person.cached_translators_count
app/controllers/application_controller.rb Show resolved Hide resolved
app/controllers/application_controller.rb Show resolved Hide resolved
@@ -25,12 +26,8 @@ class Expression < ApplicationRecord

validates :intellectual_property, presence: true

def editors
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is dangerous, as now editors can be declared both on Expression and Work level.
So we need to use Manifestation.involved_authorities_by_role instead.

Copy link
Owner

@abartov abartov May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand: why can't we return the editors associated with the Expression here? How would calling it on the Manifestation disambiguate? It seems, on the contrary, that on the Manifestation we would have ambiguity about Work-level editors and Expression-level editors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... Probably I used wrong wording.

I wrote this comment while thinking about: https://github.com/abartov/bybeconv/blob/5f265048d8286dfc8fef6cf429feb7d98f6ab50a/app/controllers/manifestation_controller.rb#L845C1-L847C1
I believe in that case we should fetch illustrators and editors both from Work and Expression. So I've added Manifestation.involved_authorities_by_role method for that puropse which merges values from Work and Expression.

And there is an involved_authorities_by_role method in Work and Expression too if we need value from specific level.

app/models/html_file.rb Show resolved Hide resolved
app/views/admin/missing_languages.html.haml Show resolved Hide resolved
@@ -0,0 +1,17 @@
%h3= t(:associated_persons)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created this partial to replaces old shared/associated_people partial to reduce code duplication

@damisul damisul requested a review from abartov May 14, 2024 11:10
expose :texts,
documentation: { desc: 'ID numbers of all texts this person is involved into with with role in each' },
if: ->(_person, options) { %w(texts enriched).include?(options[:detail]) } do
InvolvedAuthority.roles.each_key do |role|
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing all available roles including newly added

Manifestation.all_published.joins(expression: [work: :creations]).where("creations.person_id = #{self.id}")
Manifestation.all_published
.joins(expression: [work: :involved_authorities])
.where(involved_authorities: { person_id: id })
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this include translations, too? This is supposed to return only Manifestations where this person is NOT the translator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... I believe this will not include translators, because translator can only be specified on Expression level (we have validation for this). But this will include all works where Person has any role possible on Work level (e.g. illustrator).

I wonder if we should limit it to return only works where person is an author? In this case I'd propose to remove this method at all and use new Person.published_manifestations(:author) method instead. @abartov WDYT?

end

def original_work_count_including_unpublished
Manifestation.joins(expression: { work: :creations }).merge(Creation.where(person_id: self.id)).count
Manifestation.joins(expression: { work: :involved_authorities })
.merge(InvolvedAuthority.where(person_id: id)).count
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise.

Manifestation.all_published
.joins(expression: [work: :involved_authorities])
.includes(:expression)
.merge(InvolvedAuthority.where(person_id: id)).each do |m|
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise.

latest_original_works = Manifestation.all_published
.joins(expression: [work: :involved_authorities])
.where(involved_authorities: { person_id: id })
.order(created_at: :desc).limit(20)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise.

@abartov abartov merged commit bfc03b8 into master May 15, 2024
7 checks passed
@abartov abartov deleted the involved_authorities branch May 15, 2024 15:46
@damisul damisul mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants