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

[OMP] Only one featured monograph is displayed #6088

Closed
alexdryden opened this issue Jul 13, 2020 · 13 comments
Closed

[OMP] Only one featured monograph is displayed #6088

alexdryden opened this issue Jul 13, 2020 · 13 comments
Assignees
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Hosting Bug reports and feature requests from Publishing Services's hosted clients.
Milestone

Comments

@alexdryden
Copy link

Version: OMP3.2.0-3

Issue: Featured monographs share the same order index (1) by default unless they are explicitly reordered by the user. As a result only one featured monograph is displayed.

Steps to reproduce:

  1. Start with a few books and make none of them featured.
  2. Select checkboxes to make them all featured.
  3. Select "View Site" and only one title is listed as featured

Here is a diff result for the dbdump before and after explicitly ordering. First one (<) is before, second one (>) is after. The last value for each entry is the the order index, seq.

< INSERT INTO `features` VALUES (3,512,2,1),(4,512,2,1),(5,512,2,1);
---
> INSERT INTO `features` VALUES (3,512,2,2),(4,512,2,1),(5,512,2,0);

@NateWr
Copy link
Contributor

NateWr commented Jul 27, 2020

Thanks @alexdryden. This sounds like maybe a bug. Are you able to look into it further? It's probably going to be an issue with where the featured items are saved. I think that's an op like saveFeatureOrder or something like that.

@NateWr NateWr added the Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. label Jul 27, 2020
@alexdryden
Copy link
Author

alexdryden commented Jul 27, 2020

@NateWr I looked into it a little bit last week. I'm still not super familiar with the architecture, so this may not be the best solution, but it seemed like the best place to patch this would be in the insertFeature() function in the FeatureDAO class here by checking for the MAX value in the seq column and setting $seq to max value + 1.

The function is asking for the $seq value explicitly, but when this is used to simply add another publication to the list of features the default behavior should be to push it to the end of the stack of featured submissions. Right now it is just getting a $seq value of 1 in those cases. Here is my take on a solution in that function.

That solution doesn't break the saveFeaturedOrder() function, which calls insertFeature(), but instead of explicitly getting $seq passed from the form it gets it implicitly from the order of features in in the form. I'll keep looking at it and see if there is a better solution that doesn't rely on implicit ordering.

@NateWr
Copy link
Contributor

NateWr commented Jul 28, 2020

Yeah that looks like it would work, but we try to keep that kind of business logic out of the DAOs. Ideally they should just be for reading and writing data, and the logic which determines what the data looks like should be handled elsewhere.

It looks like the problem is in CatalogListItem.vue and it applies to features and new releases. Unfortunately, the proper seq to assign is not available at that level.

I think there are two options here:

  1. The code in CatalogListItem.vue that toggles featured and new release assignments and saves that data through the API could be moved to CatalogListPanel.vue. Then CatalogListItem.vue can emit an event that triggers that to happen in CatalogListPanel.vue, where the appropriate seq could be determined and assigned. This strikes me as the most appropriate route, but it requires some familiarity with Vue.js and a fair amount of refactoring on the frontend.

  2. Another option would be to explicitly not set a seq in CatalogListItem.vue, or to set it to something like -1. This could then be detected when the request is handled by the API (here). And something like the code you proposed, which got the max sequence and added it in, could be applied before insertFeature() is called.

@alexdryden
Copy link
Author

Yeah, something like option 2 was where I was heading. I'll check out option 1 first, if for no other reason then to help familiarize myself with more of the code base, and then fall back to option 2 if it seems like more work than I can fit in this week.

@mfelczak mfelczak added the Hosting Bug reports and feature requests from Publishing Services's hosted clients. label Jan 21, 2021
@mfelczak
Copy link
Member

Just adding a +1 here. This bug was recently reported from a hosted OMP install running 3.2.1-1

@alexdryden
Copy link
Author

I was working on this right around when my partner got covid and it totally fell off my radar. I can submit a pull request when I'm back in the office next week for option 2 listed above, which is I think what I implemented for us.

asmecher added a commit to asmecher/pln that referenced this issue Jun 18, 2021
@NateWr NateWr added this to the 3.5 milestone Nov 30, 2021
@iamtiagodev
Copy link

iamtiagodev commented Jan 5, 2022

This problem still happens. It's not my intention to propose a proper fix but I think I found the culprit:

SELECT submission_id, seq FROM features WHERE assoc_id = 3 ORDER BY seq;
+---------------+----------+
| submission_id | seq |
+---------------+----------+
|            10 |   1  |
|            11 |   1  |
+---------------+----------+

When the featured checkbox is ticked, it will add a new entry to features table with default sequence value as 1.
If a sequence value is duplicated it will produce unexpected results uppon using array_flip function here

I think the proper fix should be calculating sequence value based on the last stored value upon creating it.

@NateWr
Copy link
Contributor

NateWr commented Jan 10, 2022

Good hunting, @duozhasht! We've proposed a couple of possible approaches to getting the correct value stored in this comment. I think the second approach is probably the better.

We're open to a PR from the community on this, or we'll try to get to it as part of our next major release cycle.

@thiagolepidus
Copy link

thiagolepidus commented Jan 25, 2022

A similar problem is occurring when saving the features order, limiting the number of featured monographs to 30. This occurs because only items present on the current page of the "Oder Features" tab are saved.

Mysql query before save order:

SELECT COUNT(*) FROM features;
+----------+
| COUNT(*) |
+----------+
|       50 |
+----------+
1 row in set (0,00 sec)

mysql query after save order:

SELECT COUNT(*) FROM features;
+----------+
| COUNT(*) |
+----------+
|       30 |
+----------+
1 row in set (0,00 sec)

We have created an issue about this: #7648

@kaitlinnewson
Copy link
Member

kaitlinnewson commented Oct 9, 2024

PRs:

@bozana are you available to review this? I followed a similar approach to what is used for resequence() in ContextDAO.

I also fixed a small CSRF issue I encountered (related to migration work done in #9566).

I targeted this against main due to the issue's milestone, but can back-port once approved.

bozana added a commit to pkp/omp that referenced this issue Oct 21, 2024
@bozana
Copy link
Collaborator

bozana commented Oct 21, 2024

All well and merged to mein @kaitlinnewson. Thanks a lot!

kaitlinnewson added a commit to kaitlinnewson/omp that referenced this issue Oct 22, 2024
kaitlinnewson added a commit to kaitlinnewson/omp that referenced this issue Oct 22, 2024
@kaitlinnewson
Copy link
Member

@bozana Backported and the new PRs are listed above.

bozana added a commit to pkp/omp that referenced this issue Oct 23, 2024
bozana added a commit to pkp/omp that referenced this issue Oct 23, 2024
@bozana
Copy link
Collaborator

bozana commented Oct 23, 2024

Thanks @kaitlinnewson!
All merged, thus closing...

@bozana bozana closed this as completed Oct 23, 2024
@kaitlinnewson kaitlinnewson modified the milestones: 3.5.0 LTS, 3.3.0-20 Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Hosting Bug reports and feature requests from Publishing Services's hosted clients.
Projects
None yet
Development

No branches or pull requests

7 participants