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

Merge develop and make a release v6.3 #307

Merged
merged 5 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion bin/populate_env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ brand_name="${REACT_APP_UI_BRAND_NAME}"
tranql_url="${REACT_APP_TRANQL_URL:-\/tranql}"
hidden_result_tabs="${REACT_APP_HIDDEN_RESULT_TABS}"
deployment_namespace="${REACT_APP_DEPLOYMENT_NAMESPACE}"
appstore_asset_branch="${REACT_APP_APPSTORE_ASSET_BRANCH}"
appstore_asset_base_url="${REACT_APP_APPSTORE_ASSET_BASE_URL:-https:\/\/raw.githubusercontent.com\/helxplatform\/appstore}"
appstore_asset_branch="${REACT_APP_APPSTORE_ASSET_BRANCH:-master}"
analytics_enabled="${REACT_APP_ANALYTICS_ENABLED:-false}"
analytics_platform="${REACT_APP_ANALYTICS_PLATFORM}"
analytics_token="${REACT_APP_ANALYTICS_TOKEN}"
Expand All @@ -40,6 +41,7 @@ template='{
},
"hidden_result_tabs": "%HIDDEN_RESULT_TABS%",
"deployment_namespace": "%DEPLOYMENT_NAMESPACE%",
"appstore_asset_base_url": "%APPSTORE_ASSET_BASE_URL%",
"appstore_asset_branch": "%APPSTORE_ASSET_BRANCH%",
"meta": {
"title": "%META_TITLE%",
Expand All @@ -62,6 +64,7 @@ echo "$template" | sed \
-e "s/%HIDDEN_RESULT_TABS%/$hidden_result_tabs/" \
-e "s/%TRANQL_URL%/$tranql_url/" \
-e "s/%DEPLOYMENT_NAMESPACE%/$deployment_namespace/" \
-e "s/%APPSTORE_ASSET_BASE_URL%/$appstore_asset_base_url/" \
-e "s/%APPSTORE_ASSET_BRANCH%/$appstore_asset_branch/" \
-e "s/%ANALYTICS_ENABLED%/$analytics_enabled/" \
-e "s/%ANALYTICS_PLATFORM%/$analytics_platform/" \
Expand Down
37 changes: 23 additions & 14 deletions src/components/search/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export const useHelxSearch = () => useContext(HelxSearchContext)

const PER_PAGE = 20

// The maximum number of search results to retrieve when calling /search_var.
// "Pain" has 2095 elements, so limiting this to 3000 is probably fine for now.
const MAX_SEARCH_VAR_SIZE = 3000

// The maximum number of search results to retrieve when calling /search_var
// from the fetchAllVariables() function. I assume this is used in variable
// search, and so needs to be able to grab _all_ possible variables.
const MAX_SEARCH_VAR_ALL_VARIABLES_SIZE = 10000

export const SearchLayout = Object.freeze({
GRID: 'GRID',
// LIST: 'LIST',
Expand Down Expand Up @@ -51,17 +60,17 @@ export const HelxSearch = ({ children }) => {
const inputRef = useRef()
const navigate = useNavigate()
const [searchHistory, setSearchHistory] = useLocalStorage('search_history', [])

/** Abort controllers */
const fetchConceptsController = useRef()
const searchSelectedResultController = useRef()

// const selectedResultLoading = useMemo(() => selectedResult && selectedResult.loading === true, [selectedResult])
// const selectedResultFailed = useMemo(() => selectedResult && selectedResult.failed === true, [selectedResult])

/** Decorate `selectedResult` with fields:
* - previousResult: the last value of `selectedResult`
*
*
*/
const setSelectedResult = useCallback((result) => {
// Make sure to cancel searchSelectedResult requests so that calls to it don't override state with stale data.
Expand Down Expand Up @@ -118,8 +127,8 @@ export const HelxSearch = ({ children }) => {
let foundConceptResult,
synonymousConcepts,
results


if (searchSelectedResultController.current) searchSelectedResultController.current.abort()
searchSelectedResultController.current = new AbortController()

Expand Down Expand Up @@ -155,7 +164,7 @@ export const HelxSearch = ({ children }) => {
if (!conceptPages[currentPage]) return []
else return conceptPages[currentPage]
}, [conceptPages, currentPage])

const setLayout = (newLayout) => {
// Only track when layout changes
if (layout !== newLayout) {
Expand Down Expand Up @@ -318,7 +327,7 @@ export const HelxSearch = ({ children }) => {
concept: _id,
index: 'variables_index',
query: _query,
size: 1000
size: MAX_SEARCH_VAR_SIZE,
}, axiosOptions)
if (!result) {
return []
Expand All @@ -327,7 +336,7 @@ export const HelxSearch = ({ children }) => {
.reduce((studies, key) => {
if (key !== "cde") {
const newStudies = [...result[key].map(item => ({ type: key, ...item }))]
return [...newStudies, ...studies]
return [...newStudies, ...studies]
}
return [...studies]
}, [])
Expand All @@ -345,7 +354,7 @@ export const HelxSearch = ({ children }) => {
concept: _id,
index: 'variables_index',
query: _query,
size: 1000
size: MAX_SEARCH_VAR_SIZE,
}, axiosOptions)
if (!result) {
return null
Expand All @@ -354,7 +363,7 @@ export const HelxSearch = ({ children }) => {
.reduce((studies, key) => {
if (key === 'cde') {
const newStudies = [...result[key].map(item => ({ type: key, ...item }))]
return [...newStudies, ...studies]
return [...newStudies, ...studies]
}
return [...studies]
}, [])
Expand Down Expand Up @@ -412,7 +421,7 @@ export const HelxSearch = ({ children }) => {
variableToUpdate["study_name"] = study.c_name
variableToUpdate["withinFilter"] = "none"
variables.push(variableToUpdate)

studyToUpdate["elements"].push(variableToUpdate)
})

Expand Down Expand Up @@ -441,12 +450,12 @@ export const HelxSearch = ({ children }) => {
const params = {
index: 'variables_index',
query: query,
size: 10000
size: MAX_SEARCH_VAR_ALL_VARIABLES_SIZE,
}
const response = await axios.post(`${helxSearchUrl}/search_var`, params)
if (response.status === 200 && response.data.status === 'success' && response?.data?.result && Object.keys(response?.data?.result).length > 0) {
// Data structure of studies matches API response

// Data structure of studies matches API response
const studies = Object.entries(response.data.result).reduce((acc, [studySource, studies]) => {
studies.forEach((study) => {
study.data_source = studySource
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/environment-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const EnvironmentProvider = ({ children }) => {
let brandAssetFolder = context.brand
// `catalyst` is the supported name, but support `cat` and `bdc` as well.
if (brandAssetFolder === "cat" || brandAssetFolder === "bdc") brandAssetFolder = "bdc"
context.logo_url = `https://raw.githubusercontent.com/helxplatform/appstore/${ context.appstore_asset_branch }/appstore/core/static/images/${ brandAssetFolder }/logo.png`
context.logo_url = `${ context.appstore_asset_base_url }/${ context.appstore_asset_branch }/appstore/core/static/images/${ brandAssetFolder }/logo.png`
setContext(context);
setIsLoadingContext(false);
}
Expand Down
Loading