feat: enhanced filter

This commit is contained in:
DIYgod 2024-06-07 23:12:29 +08:00
parent 9eaab7d887
commit 78dc4cce44
No known key found for this signature in database
3 changed files with 20 additions and 3 deletions

View File

@ -2,8 +2,9 @@
"latest": [
151, 53994, 54570, 54481, 54537, 54302, 53944, 55768, 55855, 56592, 54986,
56875, 56873, 56666, 55996, 57407, 56249, 57858, 56973, 58600, 57399, 59737,
61688, 69750, 62764, 70101, 70194, 70191, 70146, 70190, 70189, 70188, 70187, 70186, 70182
61688, 69750, 62764, 70101, 70146, 70188
],
"comment": [54986],
"comment_content": ["snowcherryblossom"]
"comment_content": ["snowcherryblossom"],
"post_content": ["R851UX3N", "BLBKKBVT", "biyijia"]
}

View File

@ -83,6 +83,12 @@ export async function getFeed({
}
`
const contentFilterQuery = filter.post_content
.map((content) => {
return `{ content: { path: "content", string_contains: "${content}" } }`
})
.join(",\n")
let resultAll: {
list: ExpandedNote[]
cursor?: string | null
@ -127,7 +133,7 @@ export async function getFeed({
path: "tags",
array_starts_with: "short" # TODO: remove this
}
}]
}, ${contentFilterQuery}]
},
},
orderBy: [{ createdAt: desc }],

View File

@ -30,6 +30,8 @@ import {
} from "~/lib/types"
import { client } from "~/queries/graphql"
import filter from "../../data/filter.json"
export const PINNED_PAGE_KEY = "xlog_pinned_page"
export async function checkPageSlug(input: {
@ -175,6 +177,13 @@ export async function getPagesBySite(input: {
}`,
)
.join(", ")
const contentFilterQuery = filter.post_content
.map((content) => {
return `{ content: { path: "content", string_contains: "${content}" } }`
})
.join(",\n")
const whereQuery = `
{
characterId: {
@ -189,6 +198,7 @@ export async function getPagesBySite(input: {
equals: false,
},
metadata: {
NOT: [${contentFilterQuery}],
AND: [
{
content: {