Skip to content

Commit

Permalink
feat: enhanced filter
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jun 7, 2024
1 parent 9eaab7d commit 78dc4cc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 3 additions & 2 deletions data/filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
8 changes: 7 additions & 1 deletion src/models/home.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -127,7 +133,7 @@ export async function getFeed({
path: "tags",
array_starts_with: "short" # TODO: remove this
}
}]
}, ${contentFilterQuery}]
},
},
orderBy: [{ createdAt: desc }],
Expand Down
10 changes: 10 additions & 0 deletions src/models/page.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand All @@ -189,6 +198,7 @@ export async function getPagesBySite(input: {
equals: false,
},
metadata: {
NOT: [${contentFilterQuery}],
AND: [
{
content: {
Expand Down

0 comments on commit 78dc4cc

Please sign in to comment.