add booosts to newsletter script
This commit is contained in:
parent
d30dace266
commit
b6dcee4f26
@ -1,8 +1,8 @@
|
|||||||
const { ApolloClient, InMemoryCache, HttpLink, gql } = require('@apollo/client')
|
const { ApolloClient, InMemoryCache, HttpLink, gql } = require('@apollo/client')
|
||||||
|
|
||||||
const ITEMS = gql`
|
const ITEMS = gql`
|
||||||
query items ($sort: String, $when: String, $sub: String) {
|
query items ($sort: String, $when: String, $sub: String, $by: String) {
|
||||||
items (sort: $sort, when: $when, sub: $sub) {
|
items (sort: $sort, when: $when, sub: $sub, by: $by) {
|
||||||
cursor
|
cursor
|
||||||
items {
|
items {
|
||||||
id
|
id
|
||||||
@ -15,6 +15,7 @@ const ITEMS = gql`
|
|||||||
location
|
location
|
||||||
remote
|
remote
|
||||||
boost
|
boost
|
||||||
|
subName
|
||||||
user {
|
user {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -157,16 +158,11 @@ async function main () {
|
|||||||
variables: { sort: 'top', when: 'week', sub: 'ama' }
|
variables: { sort: 'top', when: 'week', sub: 'ama' }
|
||||||
})
|
})
|
||||||
|
|
||||||
const jobs = await client.query({
|
const boosts = await client.query({
|
||||||
query: ITEMS,
|
query: ITEMS,
|
||||||
variables: { sub: 'jobs' }
|
variables: { sort: 'top', when: 'forever', by: 'boost' }
|
||||||
})
|
})
|
||||||
|
|
||||||
// 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 topMeme = await bountyWinner('meme monday')
|
||||||
const topFact = await bountyWinner('fun fact')
|
const topFact = await bountyWinner('fun fact')
|
||||||
|
|
||||||
@ -242,9 +238,12 @@ ${topCowboys.map((user, i) =>
|
|||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
##### Promoted jobs
|
##### Top Boosts
|
||||||
${jobs.data.items.items.filter(i => i.boost > 0).slice(0, 5).map((item, i) =>
|
${boosts.data.items.items.map((item, i) =>
|
||||||
`${i + 1}. [${item.title.trim()} \\ ${item.company} \\ ${item.location}${item.remote ? ' or Remote' : ''}](https://stacker.news/items/${item.id})\n`).join('')}
|
item.subName === 'jobs'
|
||||||
|
? `${i + 1}. [${item.title.trim()} \\ ${item.company} \\ ${item.location}${item.remote ? ' or Remote' : ''}](https://stacker.news/items/${item.id})\n`
|
||||||
|
: `${i + 1}. [${item.title.trim()}](https://stacker.news/items/${item.id})\n`
|
||||||
|
).join('')}
|
||||||
|
|
||||||
[**all jobs**](https://stacker.news/~jobs)
|
[**all jobs**](https://stacker.news/~jobs)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user