remove dead gql

This commit is contained in:
keyan 2023-11-21 17:26:24 -06:00
parent 4a35c13ff3
commit 8e01568622
5 changed files with 17 additions and 11 deletions

View File

@ -891,8 +891,8 @@ export default {
return comments(me, models, item.id, sort || defaultCommentSort(item.pinId, item.bioId, item.createdAt))
},
wvotes: async (item) => {
return item.weightedVotes - item.weightedDownVotes
freedFreebie: async (item) => {
return item.weightedVotes - item.weightedDownVotes > 0
},
meSats: async (item, args, { me, models }) => {
if (!me) return 0

View File

@ -87,7 +87,6 @@ export default gql`
commentSats: Int!
lastCommentAt: Date
upvotes: Int!
wvotes: Float!
meSats: Int!
meDontLike: Boolean!
meBookmark: Boolean!
@ -95,6 +94,7 @@ export default gql`
meForward: Boolean
outlawed: Boolean!
freebie: Boolean!
freedFreebie: Boolean!
bio: Boolean!
paidImgLink: Boolean
ncomments: Int!

View File

@ -100,7 +100,7 @@ export default function Comment ({
}) {
const [edit, setEdit] = useState()
const me = useMe()
const isHiddenFreebie = !me?.privates?.wildWestMode && !me?.privates?.greeterMode && !item.mine && item.freebie && item.wvotes <= 0
const isHiddenFreebie = !me?.privates?.wildWestMode && !me?.privates?.greeterMode && !item.mine && item.freebie && !item.freedFreebie
const [collapse, setCollapse] = useState(
isHiddenFreebie || item?.user?.meMute
? 'yep'

View File

@ -18,7 +18,7 @@ export const COMMENT_FIELDS = gql`
sats
meAnonSats @client
upvotes
wvotes
freedFreebie
boost
meSats
meDontLike

View File

@ -27,7 +27,6 @@ const ITEM_SEARCH_FIELDS = gql`
location
remote
upvotes
wvotes
sats
boost
lastCommentAt
@ -36,7 +35,7 @@ const ITEM_SEARCH_FIELDS = gql`
ncomments
}`
async function _indexItem (item) {
async function _indexItem (item, { models }) {
console.log('indexing item', item.id)
// HACK: modify the title for jobs so that company/location are searchable
@ -55,6 +54,13 @@ async function _indexItem (item) {
itemcp.text = removeMd(item.text)
}
const itemdb = await models.item.findUnique({
where: { id: Number(item.id) },
select: { weightedVotes: true, weightedDownVotes: true }
})
itemcp.wvotes = itemdb.weightedVotes - itemdb.weightedDownVotes
try {
await search.index({
id: item.id,
@ -75,7 +81,7 @@ async function _indexItem (item) {
console.log('done indexing item', item.id)
}
export function indexItem ({ apollo }) {
export function indexItem ({ apollo, models }) {
return async function ({ data: { id } }) {
console.log('indexing item, fetching ...', id)
// 1. grab item from database
@ -92,11 +98,11 @@ export function indexItem ({ apollo }) {
})
// 2. index it with external version based on updatedAt
await _indexItem(item)
await _indexItem(item, { models })
}
}
export function indexAllItems ({ apollo }) {
export function indexAllItems ({ apollo, models }) {
return async function () {
// cursor over all items in the Item table
let items = []; let cursor = null
@ -118,7 +124,7 @@ export function indexAllItems ({ apollo }) {
// for all items, index them
try {
items.forEach(_indexItem)
items.forEach(i => _indexItem(i, { models }))
} catch (e) {
// ignore errors
console.log(e)