-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #973 from research-software-directory/955-improve-…
…performance 955 improve performance
- Loading branch information
Showing
28 changed files
with
280 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
-- SPDX-FileCopyrightText: 2022 - 2023 Netherlands eScience Center | ||
-- SPDX-FileCopyrightText: 2022 Dusan Mijatovic (dv4all) | ||
-- SPDX-FileCopyrightText: 2022 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
-- SPDX-FileCopyrightText: 2022 Netherlands eScience Center | ||
-- SPDX-FileCopyrightText: 2022 dv4all | ||
-- SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
@@ -41,6 +42,7 @@ CREATE TRIGGER sanitise_update_image BEFORE UPDATE ON image FOR EACH ROW EXECUTE | |
|
||
-- ---------------------------------------- | ||
-- RPC to get image by id => sha-1 of data | ||
-- cache incrased to 1 year based on lighthouse audit | ||
-- ---------------------------------------- | ||
|
||
CREATE FUNCTION get_image(uid VARCHAR(40)) RETURNS BYTEA STABLE LANGUAGE plpgsql AS | ||
|
@@ -52,7 +54,7 @@ BEGIN | |
SELECT format( | ||
'[{"Content-Type": "%s"},' | ||
'{"Content-Disposition": "inline; filename=\"%s\""},' | ||
'{"Cache-Control": "max-age=259200"}]', | ||
'{"Cache-Control": "max-age=31536001"}]', | ||
mime_type, | ||
uid) | ||
FROM image WHERE id = uid INTO headers; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all) (dv4all) | ||
// SPDX-FileCopyrightText: 2022 - 2023 dv4all | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
// | ||
|
@@ -21,7 +22,7 @@ import projectState from '../__mocks__/editProjectState' | |
|
||
const mockGetImpactForProject = jest.fn((props) => Promise.resolve(mockImpactForProject)) | ||
jest.mock('~/utils/getProjects', () => ({ | ||
getImpactForProject: jest.fn((props)=>mockGetImpactForProject(props)) | ||
getMentionsForProject: jest.fn((props)=>mockGetImpactForProject(props)) | ||
})) | ||
|
||
const mockGetMentionByDoiFromRsd = jest.fn((props) => Promise.resolve([] as any)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
|
@@ -10,7 +11,7 @@ import ImportMentions from '~/components/mention/ImportMentions/index' | |
import ImportMentionsInfoPanel from '~/components/mention/ImportMentions/ImportMentionsInfoPanel' | ||
import useEditMentionReducer from '~/components/mention/useEditMentionReducer' | ||
import useProjectContext from '~/components/projects/edit/useProjectContext' | ||
import {getImpactForProject} from '~/utils/getProjects' | ||
import {getMentionsForProject} from '~/utils/getProjects' | ||
import {cfgImpact as config} from './config' | ||
|
||
export default function ImportProjectImpact() { | ||
|
@@ -20,7 +21,7 @@ export default function ImportProjectImpact() { | |
|
||
async function reloadImpact() { | ||
setLoading(true) | ||
const data = await getImpactForProject({project: project.id, token: token, frontend: true}) | ||
const data = await getMentionsForProject({project: project.id,table:'impact_for_project',token: token}) | ||
setMentions(data) | ||
setLoading(false) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all) | ||
// SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
|
@@ -22,7 +23,7 @@ import outputForProject from './__mocks__/outputForProject.json' | |
// MOCK getOutputForProject | ||
const mockGetOutputForProject = jest.fn((props) => Promise.resolve(outputForProject)) | ||
jest.mock('~/utils/getProjects', () => ({ | ||
getOutputForProject: jest.fn((props)=>mockGetOutputForProject(props)) | ||
getMentionsForProject: jest.fn((props)=>mockGetOutputForProject(props)) | ||
})) | ||
// MOCK getMentionByDoiFromRsd | ||
const mockGetMentionByDoiFromRsd = jest.fn((props) => Promise.resolve([] as any)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
frontend/components/projects/overview/list/ListImageWithGradientPlaceholder.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import useValidateImageSrc from '~/utils/useValidateImageSrc' | ||
|
||
export default function ListImageWithGradientPlaceholder({imgSrc,alt}:{imgSrc:string|null, alt:string|null}) { | ||
const validImg = useValidateImageSrc(imgSrc) | ||
|
||
// console.group('ListItemImageWithGradientPlaceholder') | ||
// console.log('imgSrc...', imgSrc) | ||
// console.log('validImg...', validImg) | ||
// console.groupEnd() | ||
|
||
if (validImg === false || imgSrc === null){ | ||
// return gradient square as placeholder | ||
return ( | ||
<div | ||
className="w-12 self-stretch bg-gradient-to-br from-base-300 from-0% via-base-100 via-50% to-base-100" | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<img | ||
src={`${imgSrc ?? ''}`} | ||
alt={alt ?? 'Image'} | ||
className="w-12 max-h-[3.5rem] text-base-content-disabled p-2 object-contain object-center" | ||
// lighthouse audit requires explicit width and height | ||
height="2.5rem" | ||
width="100%" | ||
/> | ||
) | ||
} |
Oops, something went wrong.