From 855256816e1886872aab297f4149c879a91187f2 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sun, 30 Jan 2022 15:30:49 -0600 Subject: [PATCH] Include tags in contract search --- web/components/contracts-list.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/components/contracts-list.tsx b/web/components/contracts-list.tsx index a3a3bbc8..c28f9251 100644 --- a/web/components/contracts-list.tsx +++ b/web/components/contracts-list.tsx @@ -122,12 +122,13 @@ function CreatorContractsGrid(props: { contracts: Contract[] }) { function TagContractsGrid(props: { contracts: Contract[] }) { const { contracts } = props - const contractTags = _.flatMap(contracts, (contract) => - parseTags(contract.question + ' ' + contract.description).map((tag) => ({ + const contractTags = _.flatMap(contracts, (contract) => { + const { tags } = contract + return tags.map((tag) => ({ tag, contract, })) - ) + }) const groupedByTag = _.groupBy(contractTags, ({ tag }) => tag) const byTag = _.mapValues(groupedByTag, (contractTags) => contractTags.map(({ contract }) => contract) @@ -210,7 +211,8 @@ export function SearchableGrid(props: { check(c.question) || check(c.description) || check(c.creatorName) || - check(c.creatorUsername) + check(c.creatorUsername) || + check(c.lowercaseTags.map((tag) => `#${tag}`).join(' ')) ) if (sort === 'newest' || sort === 'all') {