improve newsletter script
This commit is contained in:
parent
572103b2e3
commit
efc566c3da
@ -66,15 +66,18 @@ async function bountyWinner (q) {
|
|||||||
variables: { q: `${q} nym:sn`, sort: 'recent', what: 'posts', when: 'week' }
|
variables: { q: `${q} nym:sn`, sort: 'recent', what: 'posts', when: 'week' }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const items = bounty.data.search.items.filter(i => i.bountyPaidTo?.length > 0)
|
||||||
|
if (items.length === 0) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const item = await client.query({
|
const item = await client.query({
|
||||||
query: WINNER,
|
query: WINNER,
|
||||||
variables: { id: bounty.data.search.items[0].bountyPaidTo[0] }
|
variables: { id: items[0].bountyPaidTo[0] }
|
||||||
})
|
})
|
||||||
|
|
||||||
const winner = { ...item.data.item, image: Object.values(item.data.item.imgproxyUrls)[0]?.['640w'] }
|
const winner = { ...item.data.item, image: Object.values(item.data.item.imgproxyUrls)[0]?.['640w'] }
|
||||||
|
|
||||||
return { bounty: bounty.data.search.items[0].id, winner }
|
return { bounty: items[0].id, winner }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user