fix: home Fiction queries

This commit is contained in:
DIYgod
2023-07-11 22:01:08 +01:00
parent 289e7b4c67
commit 9f308bff23
+47 -14
View File
@@ -210,6 +210,17 @@ export async function getFeed({
}
}
const includeString = [
...(topicIncludeKeywords?.map(
(topicIncludeKeyword) =>
`{ content: { path: "title", string_contains: "${topicIncludeKeyword}" } }, { content: { path: "content", string_contains: "${topicIncludeKeyword}" } }`,
) || []),
...(topicIncludeTags?.map(
(topicIncludeTag) =>
`{ content: { path: "tags", array_contains: "${topicIncludeTag}" } },`,
) || []),
].join("\n")
if (noteIds) {
const orString = noteIds
.map(
@@ -222,11 +233,42 @@ export async function getFeed({
const result = await client
.query(
`
query getNotes {
query getNotes($filter: [Int!]) {
notes(
where: {
characterId: {
notIn: $filter
},
metadata: {
content: {
path: "sources",
array_contains: "xlog"
}
}
OR: [
${orString}
{
metadata: {
content: {
path: "sources",
array_contains: "xlog"
},
AND: [{
content: {
path: "tags",
array_contains: "post"
}
}, {
OR: [
${includeString}
]
}]
}
}
{
OR: [
${orString}
]
}
]
},
orderBy: [{ createdAt: desc }],
@@ -258,7 +300,9 @@ export async function getFeed({
}
}
}`,
{},
{
filter: filter.latest,
},
)
.toPromise()
@@ -282,17 +326,6 @@ export async function getFeed({
count: list?.length || 0,
}
} else {
const includeString = [
...(topicIncludeKeywords?.map(
(topicIncludeKeyword) =>
`{ content: { path: "title", string_contains: "${topicIncludeKeyword}" } }, { content: { path: "content", string_contains: "${topicIncludeKeyword}" } }`,
) || []),
...(topicIncludeTags?.map(
(topicIncludeTag) =>
`{ content: { path: "tags", array_contains: "${topicIncludeTag}" } },`,
) || []),
].join("\n")
const result = await client
.query(
`