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

BZ-9424 SerSol 360 Handles Duplicate ISSNs #140

Merged
merged 8 commits into from
Dec 17, 2024

Conversation

Evroble
Copy link
Contributor

@Evroble Evroble commented Dec 10, 2024

Summary - BZ-9424

A customer reported seeing duplicate links on one entry when searching for a specific journal. We had seen a similar issue before in https://thirdiron.atlassian.net/browse/BZ-5276 and thought we had solved it. This time, the issue has stemmed from duplicate issns being listed, something we did not account for previously. This change adjusts the code to account for duplicate issns and ensure our links are not placed on the same listing multiple times.

Description

BEFORE:
image

AFTER:
CleanShot 2024-12-10 at 14 58 23

Implementation Notes

The change largely involves two functions getIssn and getTarget

1). getIssn - this change involves targeting the first issn listed rather than the last, as it seems to be the one more often referenced/used.

2). getTarget - this change involves taking the index from titles.forEach and using it to pair the appropriate title with the appropriate element so titles[0] attaches to elements[0].

Deploy Prerequisites

  • None

Deploy Precautions

  • None

Deploy Informational Notes

  • None

@karlbecker
Copy link
Member

Hey @Evroble , I think the commit I pushed should get tests passing.

I think searchResultsCtrl has to be the name of the element after $scope, because that's what this part of the Summon adapter expects:

function getTitles(scope) {
var titles = [];
if (scope) {
if (scope.searchResultsCtrl) {
if (scope.searchResultsCtrl.titleData) {
if (scope.searchResultsCtrl.titleData.titles) {
titles = angular.copy(scope.searchResultsCtrl.titleData.titles);
}
}
}
}
return titles;
};

Let me know if you agree - thanks!

Copy link
Member

@karlbecker karlbecker left a comment

Choose a reason for hiding this comment

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

Overall LGTM @Evroble , but we'll need to delete some of these console logs, and probably one of the comments, as long as the test change I made looks good.

Nice job on the sleuthing and getting to the bottom of this mystery! Once those console logs are gone, this is good to merge.

@@ -351,23 +351,6 @@ describe("SerSol 360 Core Model >", function() {
});
});

describe("serSol360Core model getEndpoint method >", function() {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for axing the duplicate 👍

Comment on lines 254 to 258
/* NOTE to Karl:
Essentially what i've tried to do is fully seperate this test from the others, but the code seems to refuse to recognize the data that i've set up
I've added logs so you can run locally and see what i'm seeing, but it seems like it's not recognizing the data
Previously I tried using 'searchResults' instead of 'searchResultsSameIssn' but then I was getting data from the core test again
*/
Copy link
Member

Choose a reason for hiding this comment

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

If my changes look good we should be able to remove this comment.

Comment on lines +62 to +66
if (index >= elements.length) {
var target = undefined;
} else {
var target = elements[index];
}
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 this should work - if you wanted to keep the ternary approach, you could also just do:

var target = element.length > index ? element[index] : undefined;

Since index is 0-based, and length is 1 based, then it should work fine.

Comment on lines 83 to 84
console.log(titles.length, 'how many titles do we have?');
console.log(titles, 'our titles');
Copy link
Member

Choose a reason for hiding this comment

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

🔥

title.endpoint = getEndpoint(issn);
title.shouldEnhance = shouldEnhance(issn);

if (title.shouldEnhance) {
titlesToEnhance.push(title);
}
console.log(titles, 'our list of titles');
Copy link
Member

Choose a reason for hiding this comment

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

🔥


var target = element.length > 0 ? element[0] : undefined;
function getTarget(index) {
console.log(index, 'our index inside getTarget');
Copy link
Member

Choose a reason for hiding this comment

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

🔥

@Evroble Evroble requested a review from karlbecker December 16, 2024 18:05
@Evroble
Copy link
Contributor Author

Evroble commented Dec 16, 2024

@karlbecker - so I believe i've figured out why my tests won't pass. I left a note in the code but basically in our tests we mock the response through the call $.getJSON - however in the code, it is expecting only one response, and if there are more than one, it only takes the first. This means I can't really set up the case where multiple titles are getting enhanced, or at least I can't figure out how to set it up in a way to mock that. Once you're back, let's huddle and look at this to see if we can come up with a solution, otherwise, I'm not really sure if there's a good way to test this other than to just ensure that if there are multiple instances of the same issn, we only apply it one time.

On a separate note, I'd also like us to sit down and maybe add in comments/notes about how the setup of these tests are working, because it is very confusing.

@karlbecker
Copy link
Member

Works for me @Evroble !
In the meantime if you think this fixed the bug, we can move it to testing and ship it, and consider the automated test a good future improvement.

@Evroble Evroble marked this pull request as ready for review December 16, 2024 20:05
@Evroble Evroble merged commit 3f5c179 into develop Dec 17, 2024
2 checks passed
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