Compare commits

...

2 Commits

Author SHA1 Message Date
k00b f42344497e update newsletter script 2024-08-31 14:04:49 -05:00
k00b 6dedda577b only queue autowithdraw if a wallet is enabled 2024-08-29 16:13:16 -05:00
2 changed files with 30 additions and 14 deletions

View File

@ -0,0 +1,23 @@
CREATE OR REPLACE FUNCTION user_auto_withdraw() RETURNS TRIGGER AS $$
DECLARE
BEGIN
INSERT INTO pgboss.job (name, data)
SELECT 'autoWithdraw', jsonb_build_object('id', NEW.id)
-- only if there isn't already a pending job for this user
WHERE NOT EXISTS (
SELECT *
FROM pgboss.job
WHERE name = 'autoWithdraw'
AND data->>'id' = NEW.id::TEXT
AND state = 'created'
)
-- and they have an attached wallet (currently all are received only)
AND EXISTS (
SELECT *
FROM "Wallet"
WHERE "userId" = NEW.id
AND enabled = TRUE
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

View File

@ -92,7 +92,7 @@ async function bountyWinner (q) {
const bounty = await client.query({
query: SEARCH,
variables: { q: `${q} @sn`, sort: 'recent', what: 'posts', when: 'week' }
variables: { q: `${q} @grayruby`, sort: 'recent', what: 'posts', when: 'week' }
})
const items = bounty.data.search.items.filter(i => i.bountyPaidTo?.length > 0)
@ -132,7 +132,7 @@ async function getTopUsers ({ by, cowboys = false, includeHidden = false, count
variables
})
cursor = result.data[cowboys ? 'topCowboys' : 'topUsers'].cursor
accum.push(...result.data[cowboys ? 'topCowboys' : 'topUsers'].users.filter(user => includeHidden ? true : !!user))
accum.push(...result.data[cowboys ? 'topCowboys' : 'topUsers'].users.filter(user => includeHidden ? true : !!user).filter(user => user.name !== 'k00b'))
}
} catch (e) {
@ -158,10 +158,10 @@ async function main () {
variables: { sub: 'jobs' }
})
const thisDay = await client.query({
query: SEARCH,
variables: { q: 'This Day in Stacker News @Undisciplined', sort: 'recent', what: 'posts', when: 'week' }
})
// const thisDay = await client.query({
// query: SEARCH,
// variables: { q: 'This Day in Stacker News @Undisciplined', sort: 'recent', what: 'posts', when: 'week' }
// })
const topMeme = await bountyWinner('meme monday')
const topFact = await bountyWinner('fun fact')
@ -176,7 +176,7 @@ async function main () {
Have a great weekend!
##### Top Posts
${top.data.items.items.slice(0, 10).map((item, i) =>
${top.data.items.items.map((item, i) =>
`${i + 1}. [${item.title}](https://stacker.news/items/${item.id})
- ${abbrNum(item.sats)} sats${item.boost ? ` \\ ${abbrNum(item.boost)} boost` : ''} \\ ${item.ncomments} comments \\ [@${item.user.name}](https://stacker.news/${item.user.name})\n`).join('')}
@ -192,13 +192,6 @@ ${top.data.items.items.map((item, i) =>
${meta.data.items.items.slice(0, 10).map((item, i) =>
`- [${item.title}](https://stacker.news/items/${item.id})\n`).join('')}
##### This day in Stacker News
*a series by [@Undisciplined](https://stacker.news/Undisciplined)*
${[...thisDay.data.search.items].reverse().map((item, i) =>
`- [${item.title}](https://stacker.news/items/${item.id})\n`).join('')}
[**all meta**](https://stacker.news/~meta/top/posts/week)
-------