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

pkp/pkp-lib#1660 Customizable Reviewer Recommendations #10583

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

touhidurabir
Copy link
Member

for #1660

@touhidurabir touhidurabir marked this pull request as draft November 6, 2024 11:17
@touhidurabir touhidurabir force-pushed the i1660_main branch 2 times, most recently from 756d2a1 to 3f814e5 Compare November 19, 2024 07:46
@touhidurabir touhidurabir force-pushed the i1660_main branch 3 times, most recently from a1910e2 to 05100d8 Compare December 6, 2024 11:34
@touhidurabir touhidurabir force-pushed the i1660_main branch 2 times, most recently from 0008656 to 37740ed Compare January 10, 2025 12:04
@touhidurabir touhidurabir requested a review from asmecher January 24, 2025 17:42
@touhidurabir touhidurabir force-pushed the i1660_main branch 2 times, most recently from 5784e54 to d081fbf Compare February 11, 2025 09:10
@touhidurabir touhidurabir force-pushed the i1660_main branch 4 times, most recently from ad76900 to 17dfd5a Compare February 23, 2025 17:00
@touhidurabir touhidurabir force-pushed the i1660_main branch 3 times, most recently from d481567 to 1196fdc Compare February 27, 2025 19:59
@touhidurabir touhidurabir marked this pull request as ready for review February 27, 2025 20:06
<?php

/**
* @file api/v1/reviewers/recommendations/ReviewerRecommendationController.php
Copy link
Member

Choose a reason for hiding this comment

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

This handler doesn't appear to check that the recommendation being edited/deleted exists in the current context! The manage of one journal can edit and delete recommendations that belong to another.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't that handled by ContextAccessPolicy defined in authorize so that only those have access to context can access that api end point ? And we are restricting the roles to admin, manager and editor .

Or perhaps I am misunderstanding something ?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but you're accepting any recommendation ID as user-supplied data -- and that recommendation might belong to another journal that the manager or editor doesn't manage.

public function getDefaultRecommendations(): array
{
return [
1 => 'reviewer.article.decision.accept', // SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT
Copy link
Member

Choose a reason for hiding this comment

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

I think it should be possible to eliminate the value column and just rely on a database ID. It would reduce the use of magic numbers, and mean that the options that ship with OJS are treated just like user-created options. To do this, review_assignments.recommendation would also need to be converted to a recommendation_id foreign key to the reviewer_recommendations table.

Copy link
Member Author

@touhidurabir touhidurabir Feb 28, 2025

Choose a reason for hiding this comment

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

@asmecher This is something I have been pondering for some time . What you have mentioned is one way to do it that I also thought about. But then we have some complex upgrade process as default values 1-6 is not available anymore when adding to table as primary id will be sequential . So if have 2 contexts , context-1 will have 1-6 and context-2 will have 7-12, so we have to update every review assignments for context-2 . Now for a large installation with many context and many review assignment, upgrade is even more time consuming

  1. first need to create recommendations for context
  2. map to value 1-6 with recommendations id
  3. update all review assignments for that context .

Also need a way to mark the default ones so that on local change, we can add new translations for the default ones (that is not difficult)

The current implementation does not require all these complex process and allow minimum changes to introduce this feature . Thats why I went with this path . But you are right about magic numbers and that can be the major motivation to alter it the other way as you have described . Or maybe I am overthinking here ?

Copy link
Member

Choose a reason for hiding this comment

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

If we were adding this as a brand new review feature, we would definitely use a foreign key rather than a value field. The only time we need to match a default is when we are adding a new language, and that's a boundary case (which I think is already matching on translation text, not value, right?) -- and that's a rare/boundary case already, so not justifying a different storage method.

The upgrade will be quick, even on large installs:

  1. Add a recommendation_id column to review_assignments, default null, with a FK constraint
  2. For each journal...
  3. Introduce default 6 options to reviewer_recommendations, keeping a PHP-side map from recommendation constant to recommendation_id
  4. For each default recommendation option (count=6),
    3. Update any review assignments to use the appropriate ID
  5. Drop the recommendation column from review_assignments

That's a fixed number of queries per journal -- no need to e.g. execute anything e.g. per review assignment or per submission.

@@ -171,7 +171,7 @@ public function getArrayIdByRoleId(int $roleId, ?int $contextId = null): array
*
* @return LazyCollection<int, UserGroup>
*/
public function getByRoleIds(array $roleIds, int $contextId, ?bool $default = null): LazyCollection
public function getByRoleIds(array $roleIds, ?int $contextId, ?bool $default = null): LazyCollection
Copy link
Member

Choose a reason for hiding this comment

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

Is this change intentional/necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Truthfully I don't actually remember . I will test and confirm .

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