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

SCC-3731 - Item Model #41

Merged
merged 53 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fddd342
Initialize ItemTable model
dgcohen Oct 19, 2023
774ddf6
Initialize itemUtils file
dgcohen Oct 19, 2023
c12b16b
Merge branch 'main' of github.com:NYPL/research-catalog into SCC-3731…
dgcohen Oct 26, 2023
02e91f1
Rename to Item class and update comment
dgcohen Oct 31, 2023
3cd9caf
Initialize item types and add id to Item constructor
dgcohen Oct 31, 2023
a2b9c55
Add hasItemTable helper function and Item mapping in constructor
dgcohen Oct 31, 2023
8b6e2f4
Rename to hasItems and fix logic
dgcohen Oct 31, 2023
de86fc0
Add itemSource param and initializer
dgcohen Oct 31, 2023
b2c2455
Add callnumber param
dgcohen Oct 31, 2023
d3de5be
Remove requestable and suppressed params
dgcohen Oct 31, 2023
1530b3b
Add isElectronicResource param
dgcohen Oct 31, 2023
03d83ab
Add isAvailable helper function
dgcohen Oct 31, 2023
6218c6f
Add format param
dgcohen Oct 31, 2023
44e7dd3
Add optional chaining to length checks
dgcohen Oct 31, 2023
d25d859
Remove optional chaining from item
dgcohen Oct 31, 2023
df102ad
Iniitialize location
dgcohen Nov 1, 2023
b6c9f51
Merge branch 'main' of github.com:NYPL/research-catalog into SCC-3731…
dgcohen Nov 1, 2023
f7b3300
Merge branch 'SCC-3731/item-table-model' of github.com:NYPL/research-…
dgcohen Nov 1, 2023
1d4dafd
Add location getter function
dgcohen Nov 1, 2023
1bd61c9
More refactoring on location helper
dgcohen Nov 1, 2023
bd95cd3
Add location key type
dgcohen Nov 1, 2023
97bab9f
Add getter functions to determine if item is NYPL owned
dgcohen Nov 1, 2023
2805c9f
Extract recap location logic into function
dgcohen Nov 1, 2023
b5a478c
Make item IDs required
dgcohen Nov 1, 2023
621c507
Refactor getLocationFromItem
dgcohen Nov 1, 2023
f4d3941
Add helper function isReCAP
dgcohen Nov 1, 2023
2ebf4b5
Add requestable parameters
dgcohen Nov 1, 2023
f0c0557
Remove requestable param
dgcohen Nov 1, 2023
bc3046e
Refactor identifier helpers
dgcohen Nov 1, 2023
21fca5d
Remove barcode parsing code and use API return value
dgcohen Nov 1, 2023
4d90181
Move itemUtils constants and functions to constants and item model
dgcohen Nov 2, 2023
17d7259
Add initial tests and remove console logs
dgcohen Nov 2, 2023
9a66f95
Remove check for isElectronicResource
dgcohen Nov 3, 2023
0f3de2d
Complete contructor tests
dgcohen Nov 3, 2023
61184f5
Add tests for isAvailable
dgcohen Nov 3, 2023
2db4318
Add tests for reCAP status
dgcohen Nov 3, 2023
e11c01e
Add tests for recap
dgcohen Nov 3, 2023
a6e2eef
Refactor recap tests
dgcohen Nov 3, 2023
9993050
Restore item utils and add tests
dgcohen Nov 3, 2023
cc6127e
Rename item fixtures file
dgcohen Nov 3, 2023
c52b5a8
Add JSONLDValue type
dgcohen Nov 6, 2023
d726031
Rename itemAvailabilityKeys to itemAvailableKeys
dgcohen Nov 6, 2023
e595752
Replace prefLabel check in isAvailable with id check
dgcohen Nov 6, 2023
23d18fd
Replace prefLabel check in isAvailable with id check
dgcohen Nov 6, 2023
6ac55aa
Rename isNonNYPLReCAP to isPartnerReCAP
dgcohen Nov 6, 2023
4f59625
Rename isNYPLNonReCAP to isOnsite
dgcohen Nov 6, 2023
3ed149b
Remove electronic locator from item type
dgcohen Nov 6, 2023
114e885
Derrive item id from uri field
dgcohen Nov 6, 2023
d45c251
Remove console logs
dgcohen Nov 6, 2023
d3e7486
Merge branch 'main' of github.com:NYPL/research-catalog into SCC-3731…
dgcohen Nov 7, 2023
72195aa
Merge branch 'SCC-3731/item-table-model' of github.com:NYPL/research-…
dgcohen Nov 7, 2023
0a751f2
Replace all nonNypl naming with partner
dgcohen Nov 7, 2023
ea9b690
update test name
dgcohen Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
283 changes: 283 additions & 0 deletions __test__/fixtures/itemFixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
export const itemPhysicallyRequestable = {
"@id": "res:i10572545",
"@type": ["bf:Item"],
accessMessage: [
{
"@id": "accessMessage:1",
prefLabel: "Use in library",
},
],
aeonUrl: [
"https://specialcollections.nypl.org/aeon/Aeon.dll?Action=10&Form=30&Title=Spaghetti+westerns.&Site=LPAMRAMI&CallNumber=*LDC+14245&ItemPlace=[New+York?]+:&ItemPublisher=DRG+Records+Inc.,&Date=p1995.&ItemInfo3=https://catalog.nypl.org/record=b19028235&ReferenceNumber=b190282356&ItemInfo1=USE+IN+LIBRARY&ItemNumber=33433085319782&ItemISxN=i265238791&Genre=Music+CD&Location=Performing+Arts+Music+Division",
],
catalogItemType: [
{
"@id": "catalogItemType:55",
prefLabel: "book, limited circ, MaRLI",
},
],
eddRequestable: false,
enumerationChronology: ["no. 4 (2001)"],
formatLiteral: ["Text"],
holdingLocation: [
{
"@id": "loc:mal82",
prefLabel: "Schwarzman Building - Main Reading Room 315",
},
],
idBarcode: ["33433090622188"],
identifier: [
{
"@type": "bf:ShelfMark",
"@value": "D-11 2906",
},
{
"@type": "bf:Barcode",
"@value": "33433090622188",
},
],
owner: [
{
"@id": "orgs:1101",
prefLabel: "General Research Division",
},
],
physRequestable: true,
physicalLocation: ["D-11 2906"],
requestable: [true],
shelfMark: ["D-11 2906"],
specRequestable: false,
status: [
{
"@id": "status:a",
prefLabel: "Available",
},
],
uri: "i10572545",
idNyplSourceId: {
"@type": "SierraNypl",
"@value": "10572545",
},
}

export const itemEddRequestable = {
"@id": "res:i15550040",
accessMessage: [
{
"@id": "accessMessage:2",
prefLabel: "Request in advance",
},
],
catalogItemType: [
{
"@id": "catalogItemType:55",
prefLabel: "book, limited circ, MaRLI",
},
],
eddRequestable: true,
holdingLocation: [
{
"@id": "loc:rc2ma",
prefLabel: "Offsite",
},
],
idBarcode: ["33433073236758"],
identifier: [
{
"@type": "bf:ShelfMark",
"@value": "JFC 06-438",
},
{
"@type": "bf:Barcode",
"@value": "33433073236758",
},
],
owner: [
{
"@id": "orgs:1000",
prefLabel: "Stephen A. Schwarzman Building",
},
],
physRequestable: false,
physicalLocation: ["JFC 06-438"],
recapCustomerCode: ["NA"],
requestable: [true],
shelfMark: ["JFC 06-438"],
specRequestable: false,
status: [
{
"@id": "status:a",
prefLabel: "Available",
},
],
uri: "i15550040",
idNyplSourceId: {
"@type": "SierraNypl",
"@value": "15550040",
},
}

export const itemUnavailable = {
"@id": "res:i17193499",
"@type": ["bf:Item"],
accessMessage: [
{
"@id": "accessMessage:4",
prefLabel: "Restricted use",
},
],
aeonUrl: [
"https://specialcollections.nypl.org/aeon/Aeon.dll?Action=10&Form=30&Title=On+top+of+spaghetti+[videorecording];The+Paper+Bag+Players+[present]+written,+designed,+choreographed+and+directed+by+Judith+Martin+video+produced+and+directed+by+Mary+Lou+Teel.&Site=LPATF&CallNumber=NCOV+2803&ItemPlace=Tarrytown,+N.Y.,&Date=c1996.&ItemInfo3=https://catalog.nypl.org/record=b15976955&ReferenceNumber=b159769553&ItemInfo1=RESTRICTED+USE&ItemInfo2=Restricted+to+qualified+researchers.&ItemISxN=i171934994&Genre=VHS&Location=Library+for+the+Performing+Arts+Theatre+on+Film+and+Tape+Archive",
],
catalogItemType: [
{
"@id": "catalogItemType:24",
prefLabel: "archival video recording",
},
],
eddRequestable: false,
formatLiteral: ["Moving image"],
holdingLocation: [
{
"@id": "loc:paf28",
prefLabel: "Performing Arts Research Collections - TOFT",
},
],
identifier: [
{
"@type": "bf:ShelfMark",
"@value": "NCOV 2803",
},
],
physRequestable: false,
physicalLocation: ["NCOV 2803"],
requestable: [true],
shelfMark: ["NCOV 2803"],
specRequestable: true,
status: [
{
"@id": "status:k",
prefLabel: "Check with staff",
},
],
uri: "i17193499",
idNyplSourceId: {
"@type": "SierraNypl",
"@value": "17193499",
},
}

export const itemNonNYPLReCAP = {
"@id": "res:ci1628993",
accessMessage: [
{
"@id": "accessMessage:2",
prefLabel: "Request in advance",
},
],
catalogItemType: [
{
"@id": "catalogItemType:1",
prefLabel: "non-circ",
},
],
eddRequestable: true,
idBarcode: ["CU63051249"],
identifier: [
{
"@type": "bf:ShelfMark",
"@value": "PT2676.L395 L3 1992g",
},
{
"@type": "bf:Barcode",
"@value": "CU63051249",
},
],
owner: [
{
"@id": "orgs:0002",
prefLabel: "Columbia University Libraries",
},
],
physRequestable: true,
physicalLocation: ["PT2676.L395 L3 1992g"],
recapCustomerCode: ["CU"],
requestable: [true],
shelfMark: ["PT2676.L395 L3 1992g"],
specRequestable: false,
status: [
{
"@id": "status:a",
prefLabel: "Available",
},
],
uri: "ci1628993",
idNyplSourceId: {
"@type": "RecapCul",
"@value": "1628993",
},
}

export const itemNYPLReCAP = {
"@id": "res:i10572546",
"@type": ["bf:Item"],
accessMessage: [
{
"@id": "accessMessage:2",
prefLabel: "Request in advance",
},
],
catalogItemType: [
{
"@id": "catalogItemType:55",
prefLabel: "book, limited circ, MaRLI",
},
],
eddRequestable: true,
formatLiteral: ["Text"],
holdingLocation: [
{
"@id": "loc:rc2ma",
prefLabel: "Offsite",
},
],
idBarcode: ["33433077546822"],
identifier: [
{
"@type": "bf:ShelfMark",
"@value":
"VTI (Prezzolini, G. History of spaghetti eating and cooking for: spaghetti dinner)",
},
{
"@type": "bf:Barcode",
"@value": "33433077546822",
},
],
owner: [
{
"@id": "orgs:1000",
prefLabel: "Stephen A. Schwarzman Building",
},
],
physRequestable: true,
physicalLocation: [
"VTI (Prezzolini, G. History of spaghetti eating and cooking for: spaghetti dinner)",
],
recapCustomerCode: ["NA"],
requestable: [true],
shelfMark: [
"VTI (Prezzolini, G. History of spaghetti eating and cooking for: spaghetti dinner)",
],
specRequestable: false,
status: [
{
"@id": "status:a",
prefLabel: "Available",
},
],
uri: "i10572546",
idNyplSourceId: {
"@type": "SierraNypl",
"@value": "10572546",
},
}
4 changes: 2 additions & 2 deletions src/components/DRBContainer/DRBContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Heading } from "@nypl/design-system-react-components"
import useSWRImmutable from "swr/immutable"

import { BASE_URL } from "../../config/constants"
import { BASE_URL, DRB_API_SEARCH_ROUTE } from "../../config/constants"
import type { SearchParams } from "../../types/searchTypes"
import type { DRBWork } from "../../types/drbTypes"
import { getQueryString } from "../../utils/searchUtils"
Expand All @@ -15,7 +15,7 @@ interface DRBContainerProps {
*/
const DRBContainer = ({ searchParams }: DRBContainerProps) => {
const searchQuery = getQueryString(searchParams)
const drbUrl = `${BASE_URL}/api/drb?${searchQuery}`
const drbUrl = `${BASE_URL}${DRB_API_SEARCH_ROUTE}?${searchQuery}`
const fetcher = (url: string) => fetch(url).then((res) => res.json())

const { data, error, isValidating } = useSWRImmutable(drbUrl, fetcher)
Expand Down
1 change: 1 addition & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const BASE_URL = "/research/research-catalog"
export const SITE_NAME = "NYPL Research Catalog"
export const RESULTS_PER_PAGE = 50
export const DRB_RESULTS_PER_PAGE = 3
export const ITEMS_PER_SEARCH_RESULT = 3

// Internal path names
export const PATHS = {
Expand Down
Loading