Squashed commit of the following:

commit ea934d83
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Tue Jan 14 06:59:11 2025 +0100

    [search] move EPO user/token into the datafield

commit b01a85eb
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Mon Jan 13 10:15:27 2025 +0100

    [search] search query json format fixes

    Related to haskell-gargantext#441

    Related to commmit
    haskell-gargantext@bc29319c

commit 3b50603a
Merge: a93e055b 2e43c474
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Fri Jan 10 12:04:36 2025 +0100

    Merge branch 'dev' into 204-ngrams-refactor-fixes

commit a93e055b
Author: Przemysław Kaminski <pk@intrepidus.pl>
Date:   Wed Jan 8 18:22:37 2025 +0100

    [search] pubmed constructor with api key

This commit has to be merged together with
haskell-gargantext!385 (03b33383)
parent 2e43c474
Pipeline #7290 passed with stages
in 18 minutes and 7 seconds
......@@ -55,7 +55,7 @@ searchIframesCpt = here.component "searchIframes" cpt
pure $
if isIsTex_Advanced search'.datafield then divIframe { frameSource: Istex, iframeRef, search } []
else if Just Web == search'.datafield then divIframe { frameSource: Searx, iframeRef, search } []
else if Web == search'.datafield then divIframe { frameSource: Searx, iframeRef, search } []
else H.div {} []
type IFrameProps =
......
......@@ -2,6 +2,7 @@ module Gargantext.Components.Forest.Tree.Node.Action.Search.Types where
import Gargantext.Prelude
import Data.Array as A
-- import Data.Bounded (class Bounded)
import Data.Either (Either)
-- import Data.Enum (class Enum, class BoundedEnum)
......@@ -26,23 +27,16 @@ import URI.Extra.QueryPairs as QP
import URI.Query as Q
type Search =
{ databases :: Database
, datafield :: Maybe DataField
{ datafield :: DataField
, url :: String
, lang :: Maybe Lang
, node_id :: Maybe Int
, epoApiUser :: Maybe String
, epoApiToken :: Maybe String
, pubmedApiKey :: Maybe String
, term :: String
, years :: Array String
}
isIsTex_Advanced :: Maybe DataField -> Boolean
isIsTex_Advanced
( Just
(External (IsTex_Advanced))
) = true
isIsTex_Advanced :: DataField -> Boolean
isIsTex_Advanced (External (IsTex_Advanced)) = true
isIsTex_Advanced _ = false
------------------------------------------------------------------------
......@@ -81,7 +75,7 @@ instance Doc DataField where
derive instance Eq DataField
instance JSON.WriteForeign DataField where
writeImpl (External db) = JSON.writeImpl { "External": JSON.writeImpl $ show db }
writeImpl (External db) = JSON.writeImpl { "External": db }
writeImpl Gargantext = JSON.writeImpl "Gargantext"
writeImpl Web = JSON.writeImpl "Web"
writeImpl Files = JSON.writeImpl "Files"
......@@ -116,13 +110,13 @@ data Database
= All_Databases
| Empty
| OpenAlex
| PubMed
| PubMed (Maybe String)
| Arxiv
| HAL (Maybe Org)
| IsTex
| IsTex_Advanced
| Isidore
| EPO
| EPO (Maybe String) (Maybe String)
-- | News
-- | SocialNetworks
......@@ -133,13 +127,13 @@ derive instance Generic Database _
instance Show Database where
show All_Databases = "All Databases"
show OpenAlex = "OpenAlex"
show PubMed = "PubMed"
show (PubMed _) = "PubMed"
show Arxiv = "Arxiv"
show (HAL _) = "HAL"
show IsTex = "IsTex"
show IsTex_Advanced = "IsTex_Advanced"
show Isidore = "Isidore"
show EPO = "EPO"
show (EPO _ _) = "EPO"
show Empty = "Empty"
-- show News = "News"
......@@ -148,13 +142,13 @@ instance Show Database where
instance Doc Database where
doc All_Databases = "All databases"
doc OpenAlex = "OpenAlex db"
doc PubMed = "All Medical publications"
doc (PubMed _) = "All Medical publications"
doc Arxiv = "Arxiv"
doc (HAL _) = "All open science (archives ouvertes)"
doc IsTex = "All Elsevier enriched by CNRS/INIST"
doc IsTex_Advanced = "IsTex advanced search"
doc Isidore = "All (French) Social Sciences"
doc EPO = "European Patent Office"
doc (EPO _ _) = "European Patent Office"
doc Empty = "Empty"
-- doc News = "Web filtered by News"
......@@ -176,17 +170,24 @@ instance Doc Database where
derive instance Eq Database
instance JSON.WriteForeign Database where
writeImpl f = JSON.writeImpl $ show f
writeImpl (PubMed mAPIKey) = JSON.writeImpl { "db": "PubMed", "api_key": mAPIKey }
writeImpl (EPO mAPIUser mAPIToken) = JSON.writeImpl
{ "db": "PubMed"
, "api_user": mAPIUser
, "api_token": mAPIToken
}
writeImpl (HAL mOrg) = JSON.writeImpl { "db": "HAL", "org": mOrg }
writeImpl d = JSON.writeImpl { "db": show d }
allDatabases :: Array Database
allDatabases =
[ Empty
, PubMed
, PubMed Nothing
, HAL Nothing
, Arxiv
, OpenAlex
, IsTex
-- , EPO
-- , EPO Nothing Nothing
--, IsTex_Advanced
--, Isidore
--, Web
......@@ -197,25 +198,25 @@ allDatabases =
dbToInputValue :: Database -> String
dbToInputValue All_Databases = "all_databases"
dbToInputValue OpenAlex = "openalex"
dbToInputValue PubMed = "pubmed"
dbToInputValue (PubMed _) = "pubmed"
dbToInputValue Arxiv = "arxiv"
dbToInputValue (HAL _) = "hal"
dbToInputValue IsTex = "istex"
dbToInputValue IsTex_Advanced = "istex_advanced"
dbToInputValue Isidore = "isidore"
dbToInputValue EPO = "epo"
dbToInputValue (EPO _ _) = "epo"
dbToInputValue Empty = "empty"
dbFromInputValue :: String -> Maybe Database
dbFromInputValue "all_databases" = Just All_Databases
dbFromInputValue "openalex" = Just OpenAlex
dbFromInputValue "pubmed" = Just PubMed
dbFromInputValue "pubmed" = Just (PubMed Nothing)
dbFromInputValue "arxiv" = Just Arxiv
dbFromInputValue "hal" = Just (HAL Nothing)
dbFromInputValue "istex" = Just IsTex
dbFromInputValue "istex_advanced" = Just IsTex_Advanced
dbFromInputValue "isidore" = Just Isidore
dbFromInputValue "epo" = Just EPO
dbFromInputValue "epo" = Just (EPO Nothing Nothing)
dbFromInputValue "empty" = Just Empty
dbFromInputValue _ = Nothing
......@@ -252,6 +253,9 @@ instance Read Org where
read _ = Nothing
derive instance Eq Org
-- | NOTE: IMT_org list isn't really used here in JSON
-- | encoding. Instead, for HAL, a special query is constructed in
-- | SearchField (queryHAL function).
instance JSON.WriteForeign Org where
writeImpl = JSON.writeImpl <<< show
......@@ -294,8 +298,7 @@ instance Show SearchOrder where
newtype SearchQuery = SearchQuery
{ query :: String
, databases :: Database
, datafield :: Maybe DataField
, datafield :: DataField
, files_id :: Array String
, lang :: Maybe Lang
, limit :: Maybe Int
......@@ -304,7 +307,6 @@ newtype SearchQuery = SearchQuery
, order :: Maybe SearchOrder
, epoAPIUser :: Maybe String
, epoAPIToken :: Maybe String
, pubmedAPIKey :: Maybe String
, selection :: ListSelection.Selection
}
......@@ -329,34 +331,29 @@ instance GT.ToQuery SearchQuery where
instance JSON.WriteForeign SearchQuery where
writeImpl
( SearchQuery
{ databases
, datafield
{ datafield
, lang
, node_id
, epoAPIUser
, epoAPIToken
, pubmedAPIKey
, query
, selection
}
) =
JSON.writeImpl
{ query: query -- String.replace (String.Pattern "\"") (String.Replacement "\\\"") query
, databases
, datafield
, lang: maybe "EN" show lang
, node_id: fromMaybe 0 node_id
, flowListWith: selection
, epoAPIUser
, epoAPIToken
, pubmedAPIKey
}
defaultSearchQuery :: SearchQuery
defaultSearchQuery = SearchQuery
{ query: ""
, databases: Empty
, datafield: Nothing
, datafield: External Empty
, files_id: []
, lang: Nothing
, limit: Nothing
......@@ -365,7 +362,6 @@ defaultSearchQuery = SearchQuery
, order: Nothing
, epoAPIUser: Nothing
, epoAPIToken: Nothing
, pubmedAPIKey: Nothing
, selection: ListSelection.NoList -- MyListsFirst
}
......
......@@ -68,8 +68,7 @@ asyncProgressCpt = R2.hereComponent here "asyncProgress" hCpt
here.log "[onProgress] TODO: Implement status killed"
if
GT.asyncTaskLogIsFinished atl ||
GT.asyncTaskLogIsError atl then do
GT.asyncTaskLogIsFinished atl then do
handleErrorInAsyncTaskLog errors atl
-- resetInterval intervalIdRef Nothing (pure unit)
onFinish unit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment