From cb7f68e0e53175b37d6582f65387ab34bff67cfd Mon Sep 17 00:00:00 2001 From: keyan Date: Fri, 28 Oct 2022 10:58:31 -0500 Subject: [PATCH] index wvotes for search --- api/resolvers/item.js | 4 +++- api/typeDefs/item.js | 1 + worker/search.js | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/resolvers/item.js b/api/resolvers/item.js index 7940e382..44d328f4 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -321,7 +321,6 @@ export default { const items = await models.$queryRaw(` ${SELECT} FROM "Item" - ${await filterClause(me, models)} ORDER BY created_at DESC OFFSET $1 LIMIT ${LIMIT}`, decodedCursor.offset) @@ -800,6 +799,9 @@ export default { return sats || 0 }, + wvotes: async (item) => { + return item.weightedVotes - item.weightedDownVotes + }, meSats: async (item, args, { me, models }) => { if (!me) return 0 diff --git a/api/typeDefs/item.js b/api/typeDefs/item.js index cf2f363f..2abb55a6 100644 --- a/api/typeDefs/item.js +++ b/api/typeDefs/item.js @@ -84,6 +84,7 @@ export default gql` commentSats: Int! lastCommentAt: String upvotes: Int! + wvotes: Float! meSats: Int! meDontLike: Boolean! outlawed: Boolean! diff --git a/worker/search.js b/worker/search.js index 7282f06d..27fb2ad6 100644 --- a/worker/search.js +++ b/worker/search.js @@ -23,6 +23,7 @@ const ITEM_SEARCH_FIELDS = gql` location remote upvotes + wvotes sats boost lastCommentAt