Skip to content

Commit

Permalink
🐛 bug: now searches properly after jurisdiction change
Browse files Browse the repository at this point in the history
  • Loading branch information
hueyy committed Jun 13, 2021
1 parent 1d55392 commit 19d3f04
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clerkent",
"version": "2.6.0",
"version": "2.6.1",
"private": true,
"description": "quick search for international caselaw and legislation",
"repository": "https://github.com/lacuna-technologies/clerkent.git",
Expand Down
2 changes: 1 addition & 1 deletion src/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const Popup: React.FC = () => {
if(!doNotStore){
Storage.set(keys.SELECTED_JURISDICTION, value)
}
doSearch({ inputJurisdiction: value})
doSearch({ inputJurisdiction: value })
}, [doSearch])

const applyClipboardText = useCallback((clipboardText) => {
Expand Down
16 changes: 12 additions & 4 deletions src/utils/scraper/Scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const getCaseByName = Memoize((
]) => `${targetCaseName.name.toLowerCase()}-${inputJurisdiction}`,
})

const getLegislation = Memoize(async (
const getLegislation = Memoize((
targetLegislation: LegislationFinderResult,
inputJurisdiction: Law.JursidictionCode,
): Promise<Law.Legislation[]> => {
Expand All @@ -78,6 +78,9 @@ const getLegislation = Memoize(async (
if(!targetJurisdiction || !(`getLegislation` in targetJurisdiction)){
return Promise.resolve([])
}

Logger.log(`Scraper: getLegislation`, targetLegislation, inputJurisdiction)

return (
targetJurisdiction as JurisdictionWithLegislationSearch
).getLegislation(targetLegislation)
Expand All @@ -86,10 +89,10 @@ const getLegislation = Memoize(async (
provisionType,
provisionNumber,
statute,
}]) => `${provisionType}-${provisionNumber}-${statute}`,
}, inputJurisdiction]) => `${provisionType}-${provisionNumber}-${statute}-${inputJurisdiction}`,
})

const getPDF = (inputCase: Law.Case, inputDocumentType: Law.Link[`doctype`]): Promise<string> => {
const getPDF = Memoize((inputCase: Law.Case, inputDocumentType: Law.Link[`doctype`]): Promise<string> => {
const existingLink = inputCase.links.find(({ doctype, filetype }) => doctype === inputDocumentType && filetype === `PDF`)
if(existingLink){
return Promise.resolve(existingLink?.url)
Expand All @@ -103,7 +106,12 @@ const getPDF = (inputCase: Law.Case, inputDocumentType: Law.Link[`doctype`]): Pr
return (
targetJurisdiction as any
).getPDF(inputCase, inputDocumentType)
}
}, {
normalizer: ([inputCase, inputDocumentType]) => {
const { citation, jurisdiction } = inputCase
return `${jurisdiction}-${citation}-${inputDocumentType}`
},
})

const scraper = {
AU,
Expand Down

0 comments on commit 19d3f04

Please sign in to comment.