Skip to content

Commit

Permalink
Merge pull request #778 from research-software-directory/highlights
Browse files Browse the repository at this point in the history
Merging this PR as initial version of highlights. The improvements will be handled in new issues like #838, #840, #841 etc.
  • Loading branch information
dmijatovic authored Apr 17, 2023
2 parents 70fe3ee + 99955fa commit ba2ebd6
Show file tree
Hide file tree
Showing 34 changed files with 1,967 additions and 158 deletions.
14 changes: 11 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"editor.quickSuggestions": {
"strings": true
},
"tailwindCSS.includeLanguages":{
"tailwindCSS.includeLanguages": {
"plaintext": "html"
},
"[java]": {
Expand All @@ -39,5 +39,13 @@
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false
}
}
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
}
3 changes: 3 additions & 0 deletions .vscode/settings.json.license
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
SPDX-FileCopyrightText: 2022 Netherlands eScience Center
SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
SPDX-FileCopyrightText: 2023 dv4all

SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: CC0-1.0
109 changes: 30 additions & 79 deletions database/100-create-api-views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -177,52 +177,39 @@ BEGIN
END
$$;

-- SOFTWARE OVERVIEW LIST FOR SEARCH
-- WITH COUNTS and KEYWORDS for filtering
CREATE FUNCTION software_search() RETURNS TABLE (
id UUID,
slug VARCHAR,
brand_name VARCHAR,
short_statement VARCHAR,
image_id VARCHAR,
updated_at TIMESTAMPTZ,
contributor_cnt BIGINT,
mention_cnt BIGINT,
is_published BOOLEAN,
keywords CITEXT[],
keywords_text TEXT,
prog_lang TEXT[]
) LANGUAGE plpgsql STABLE AS
-- license counts for software
-- used in software filter - license dropdown
CREATE FUNCTION license_cnt_for_software() RETURNS TABLE (
license VARCHAR,
cnt BIGINT
) LANGUAGE sql STABLE AS
$$
BEGIN
RETURN QUERY
SELECT
software.id,
software.slug,
software.brand_name,
software.short_statement,
software.image_id,
software.updated_at,
count_software_countributors.contributor_cnt,
count_software_mentions.mention_cnt,
software.is_published,
keyword_filter_for_software.keywords,
keyword_filter_for_software.keywords_text,
prog_lang_filter_for_software.prog_lang
FROM
software
LEFT JOIN
count_software_countributors() ON software.id=count_software_countributors.software
LEFT JOIN
count_software_mentions() ON software.id=count_software_mentions.software
LEFT JOIN
keyword_filter_for_software() ON software.id=keyword_filter_for_software.software
LEFT JOIN
prog_lang_filter_for_software() ON software.id=prog_lang_filter_for_software.software
;
END
SELECT
license_for_software.license,
COUNT(license_for_software.license) AS cnt
FROM
license_for_software
GROUP BY
license_for_software.license
;
$$;

-- license filter for software
-- used by software_search func
CREATE FUNCTION license_filter_for_software() RETURNS TABLE (
software UUID,
licenses VARCHAR[]
) LANGUAGE sql STABLE AS
$$
SELECT
license_for_software.software,
ARRAY_AGG(license_for_software.license)
FROM
license_for_software
GROUP BY
license_for_software.software
;
$$;

-- RELATED SOFTWARE LIST WITH COUNTS
CREATE FUNCTION related_software_for_software(software_id UUID) RETURNS TABLE (
Expand Down Expand Up @@ -1492,39 +1479,3 @@ DESC LIMIT
1;
;
$$;

-- Get a list of all software highlights with latest highlights first
CREATE FUNCTION software_for_highlight() RETURNS TABLE (
id UUID,
slug VARCHAR,
brand_name VARCHAR,
short_statement VARCHAR,
image_id VARCHAR,
is_published BOOLEAN,
contributor_cnt BIGINT,
mention_cnt BIGINT,
"position" INTEGER,
updated_at TIMESTAMPTZ
) LANGUAGE sql STABLE AS
$$
SELECT
software.id,
software.slug,
software.brand_name,
software.short_statement,
software.image_id,
software.is_published,
count_software_countributors.contributor_cnt,
count_software_mentions.mention_cnt,
software_highlight.position,
software_highlight.updated_at
FROM
software
INNER JOIN
software_highlight ON software.id=software_highlight.software
LEFT JOIN
count_software_countributors() ON software.id=count_software_countributors.software
LEFT JOIN
count_software_mentions() ON software.id=count_software_mentions.software
;
$$;
75 changes: 69 additions & 6 deletions database/103-software-views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,31 @@ CREATE FUNCTION software_overview() RETURNS TABLE (
slug VARCHAR,
brand_name VARCHAR,
short_statement VARCHAR,
image_id VARCHAR,
updated_at TIMESTAMPTZ,
contributor_cnt BIGINT,
mention_cnt BIGINT,
is_published BOOLEAN,
keywords CITEXT[],
keywords_text TEXT,
prog_lang TEXT[]
prog_lang TEXT[],
licenses VARCHAR[]
) LANGUAGE sql STABLE AS
$$
SELECT
software.id,
software.slug,
software.brand_name,
software.short_statement,
software.image_id,
software.updated_at,
count_software_countributors.contributor_cnt,
count_software_mentions.mention_cnt,
software.is_published,
keyword_filter_for_software.keywords,
keyword_filter_for_software.keywords_text,
prog_lang_filter_for_software.prog_lang
prog_lang_filter_for_software.prog_lang,
license_filter_for_software.licenses
FROM
software
LEFT JOIN
Expand All @@ -41,6 +45,8 @@ LEFT JOIN
keyword_filter_for_software() ON software.id=keyword_filter_for_software.software
LEFT JOIN
prog_lang_filter_for_software() ON software.id=prog_lang_filter_for_software.software
LEFT JOIN
license_filter_for_software() ON software.id=license_filter_for_software.software
;
$$;

Expand All @@ -52,27 +58,31 @@ CREATE FUNCTION software_search(search VARCHAR) RETURNS TABLE (
slug VARCHAR,
brand_name VARCHAR,
short_statement VARCHAR,
image_id VARCHAR,
updated_at TIMESTAMPTZ,
is_published BOOLEAN,
contributor_cnt BIGINT,
mention_cnt BIGINT,
is_published BOOLEAN,
keywords CITEXT[],
keywords_text TEXT,
prog_lang TEXT[]
prog_lang TEXT[],
licenses VARCHAR[]
) LANGUAGE sql STABLE AS
$$
SELECT
software.id,
software.slug,
software.brand_name,
software.short_statement,
software.image_id,
software.updated_at,
software.is_published,
count_software_countributors.contributor_cnt,
count_software_mentions.mention_cnt,
software.is_published,
keyword_filter_for_software.keywords,
keyword_filter_for_software.keywords_text,
prog_lang_filter_for_software.prog_lang
prog_lang_filter_for_software.prog_lang,
license_filter_for_software.licenses
FROM
software
LEFT JOIN
Expand All @@ -83,6 +93,8 @@ LEFT JOIN
keyword_filter_for_software() ON software.id=keyword_filter_for_software.software
LEFT JOIN
prog_lang_filter_for_software() ON software.id=prog_lang_filter_for_software.software
LEFT JOIN
license_filter_for_software() ON software.id=license_filter_for_software.software
WHERE
software.brand_name ILIKE CONCAT('%', search, '%')
OR
Expand Down Expand Up @@ -112,3 +124,54 @@ ORDER BY
END
;
$$;


-- Get a list of all software highlights
CREATE FUNCTION software_for_highlight() RETURNS TABLE (
id UUID,
slug VARCHAR,
brand_name VARCHAR,
short_statement VARCHAR,
image_id VARCHAR,
updated_at TIMESTAMPTZ,
is_published BOOLEAN,
contributor_cnt BIGINT,
mention_cnt BIGINT,
keywords CITEXT[],
keywords_text TEXT,
prog_lang TEXT[],
licenses VARCHAR[],
"position" INTEGER
) LANGUAGE sql STABLE AS
$$
SELECT
software.id,
software.slug,
software.brand_name,
software.short_statement,
software.image_id,
software.updated_at,
software.is_published,
count_software_countributors.contributor_cnt,
count_software_mentions.mention_cnt,
keyword_filter_for_software.keywords,
keyword_filter_for_software.keywords_text,
prog_lang_filter_for_software.prog_lang,
license_filter_for_software.licenses,
software_highlight.position
FROM
software
INNER JOIN
software_highlight ON software.id=software_highlight.software
LEFT JOIN
count_software_countributors() ON software.id=count_software_countributors.software
LEFT JOIN
count_software_mentions() ON software.id=count_software_mentions.software
LEFT JOIN
keyword_filter_for_software() ON software.id=keyword_filter_for_software.software
LEFT JOIN
prog_lang_filter_for_software() ON software.id=prog_lang_filter_for_software.software
LEFT JOIN
license_filter_for_software() ON software.id=license_filter_for_software.software
;
$$;
3 changes: 2 additions & 1 deletion frontend/components/admin/rsd-contributors/config.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all)
// SPDX-FileCopyrightText: 2023 dv4all
//
// SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -116,7 +117,7 @@ export function createColumns(token: string) {
url=`/projects/${data.slug}/edit/team`
}
return (
<a href={url} target="_blank">
<a href={url} target="_blank" rel="noreferrer">
<LaunchIcon sx={{marginRight:'0.25rem'}} fontSize="small"/>
{data.origin === 'contributor' ? 'Software' : 'Project'}
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all)
// SPDX-FileCopyrightText: 2023 dv4all
//
// SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -46,7 +47,7 @@ export default function AddSoftwareHighlights({onAddSoftware,highlights}:AddSoft
// remove items already in hightlights
const software = itemsNotInReferenceList({
list: resp.data ?? [],
referenceList: highlights ?? [],
referenceList: highlights as any as SoftwareListItem[] ?? [],
key: 'id'
})

Expand Down
Loading

0 comments on commit ba2ebd6

Please sign in to comment.