Include tags in contract search

This commit is contained in:
James Grugett 2022-01-30 15:30:49 -06:00
parent 83f4fd3555
commit 855256816e

View File

@ -122,12 +122,13 @@ function CreatorContractsGrid(props: { contracts: Contract[] }) {
function TagContractsGrid(props: { contracts: Contract[] }) { function TagContractsGrid(props: { contracts: Contract[] }) {
const { contracts } = props const { contracts } = props
const contractTags = _.flatMap(contracts, (contract) => const contractTags = _.flatMap(contracts, (contract) => {
parseTags(contract.question + ' ' + contract.description).map((tag) => ({ const { tags } = contract
return tags.map((tag) => ({
tag, tag,
contract, contract,
})) }))
) })
const groupedByTag = _.groupBy(contractTags, ({ tag }) => tag) const groupedByTag = _.groupBy(contractTags, ({ tag }) => tag)
const byTag = _.mapValues(groupedByTag, (contractTags) => const byTag = _.mapValues(groupedByTag, (contractTags) =>
contractTags.map(({ contract }) => contract) contractTags.map(({ contract }) => contract)
@ -210,7 +211,8 @@ export function SearchableGrid(props: {
check(c.question) || check(c.question) ||
check(c.description) || check(c.description) ||
check(c.creatorName) || check(c.creatorName) ||
check(c.creatorUsername) check(c.creatorUsername) ||
check(c.lowercaseTags.map((tag) => `#${tag}`).join(' '))
) )
if (sort === 'newest' || sort === 'all') { if (sort === 'newest' || sort === 'all') {