Skip to content

Commit

Permalink
Use new memberIds field for graphQl
Browse files Browse the repository at this point in the history
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>
  • Loading branch information
maxkadel and sandbergja committed Apr 21, 2023
1 parent 6ddfcd9 commit 137aaa6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 49 deletions.
7 changes: 2 additions & 5 deletions app/javascript/orangelight/figgy_manifest_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ class FiggyViewerSet {

getMemberIds(resources) {
const ids = resources.map((resource) => {
return resource.members.map((member) => {
return member.id;
});
return resource.memberIds;
});

return ids.flat();
}

Expand All @@ -94,7 +91,7 @@ class FiggyViewerSet {
// If there is a resource whose ID is included as a member_id of another resource,
// filter it out
const filterDuplicatedResources = resources.filter((resource) => {
if (!resource['members'])
if (!resource['memberIds'])
return true;
const member_ids = this.getMemberIds(resources);
const resource_is_unique = member_ids.map(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ async function loadResourcesByOrangelightId(id) {
},
label,
url,
members {
id
},
memberIds,
embed {
type,
content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ async function loadResourcesByOrangelightIds(ids) {
thumbnailUrl
},
url,
members {
id
},
memberIds,
... on ScannedResource {
manifestUrl,
orangelightId
Expand Down
52 changes: 14 additions & 38 deletions spec/javascript/orangelight/figgy_manifest_manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ describe('RelatedRecords', function() {
},
"label": "Pennsylvania: Troy Quadrangle.",
"url": "https://figgy.princeton.edu/catalog/26b01ff3-eb40-40b0-821c-42fade1cf349",
"members": [
{
"id": "85773d63-8a3a-4cea-b1c3-d9d0196bac3f",
"__typename": "FileSet"
}
"memberIds": [
"85773d63-8a3a-4cea-b1c3-d9d0196bac3f"
],
"embed": {
"type": "html",
Expand All @@ -51,15 +48,9 @@ describe('RelatedRecords', function() {
},
"label": "Pennsylvania: (Lycoming) Trout Run Quadrangle",
"url": "https://figgy.princeton.edu/catalog/a65bd135-5356-4613-8089-d90fc445cfda",
"members": [
{
"id": "595ee476-d247-4339-83e2-bddb90a7d069",
"__typename": "ScannedMap"
},
{
"id": "26b01ff3-eb40-40b0-821c-42fade1cf349",
"__typename": "ScannedMap"
}
"memberIds": [
"595ee476-d247-4339-83e2-bddb90a7d069",
"26b01ff3-eb40-40b0-821c-42fade1cf349"
],
"embed": {
"type": "html",
Expand All @@ -80,11 +71,8 @@ describe('RelatedRecords', function() {
},
"label": "Pennsylvania: (Lycoming) Trout Run Quadrangle (Lycoming)",
"url": "https://figgy.princeton.edu/catalog/595ee476-d247-4339-83e2-bddb90a7d069",
"members": [
{
"id": "8fa8bc9b-b0e9-456c-a1ee-a913b2499054",
"__typename": "FileSet"
}
"memberIds": [
"8fa8bc9b-b0e9-456c-a1ee-a913b2499054"
],
"embed": {
"type": "html",
Expand Down Expand Up @@ -124,15 +112,9 @@ describe('RelatedRecords', function() {
},
"label": "At a Council held at Boston March 8. 1679,80. : The governour and Council, upon mature consideration of the many loud calls of Providence ... Do therefore appoint and order, that the fifteenth day of April next, be set apart for a day of humiliation and prayer ...",
"url": "https://figgy.princeton.edu/catalog/bbc6f6c4-3b92-4ae9-8461-1a14c113af8c",
"members": [
{
"id": "8ecd795b-cd1b-4efc-9f1b-1411574d948c",
"__typename": "FileSet"
},
{
"id": "2e6c63af-7e2d-4191-a1b6-b4113394ce33",
"__typename": "FileSet"
}
"memberIds": [
"8ecd795b-cd1b-4efc-9f1b-1411574d948c",
"2e6c63af-7e2d-4191-a1b6-b4113394ce33"
],
"embed": {
"type": "html",
Expand All @@ -153,15 +135,9 @@ describe('RelatedRecords', function() {
},
"label": "At a Council held at Boston March 8. 1679,80. : The governour and Council, upon mature consideration of the many loud calls of Providence ... Do therefore appoint and order, that the fifteenth day of April next, be set apart for a day of humiliation and prayer ...",
"url": "https://figgy.princeton.edu/catalog/54b399c7-f28c-46f6-a7b4-c835a60516c4",
"members": [
{
"id": "b9ce8d56-2ab7-48e0-8e97-d510b904f920",
"__typename": "ScannedResource"
},
{
"id": "e3e5ba6b-e7c6-4016-8c62-fe6656c020ca",
"__typename": "ScannedResource"
}
"memberIds": [
"b9ce8d56-2ab7-48e0-8e97-d510b904f920",
"e3e5ba6b-e7c6-4016-8c62-fe6656c020ca"
],
"embed": {
"type": "html",
Expand All @@ -181,7 +157,7 @@ describe('RelatedRecords', function() {

const queryFunction = jest.fn((_bibIds) => { return graphqlResponse })
const viewerWrapperElement = document.getElementById('view');
const viewerSet = new FiggyViewerSet(viewerWrapperElement, queryFunction, '9968683243506421', null)
const viewerSet = new FiggyViewerSet(viewerWrapperElement, queryFunction, '9950403683506421', null)
await viewerSet.render()
expect(viewerWrapperElement.getElementsByTagName('iframe')).toHaveLength(2);
});
Expand Down

0 comments on commit 137aaa6

Please sign in to comment.