Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase getPopular likes to 8 #862

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions packages/pds/src/app-view/api/app/bsky/unspecced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { paginate } from '../../../../db/pagination'
import AppContext from '../../../../context'
import { FeedRow } from '../../../services/feed'
import { FeedViewPost } from '../../../../lexicon/types/app/bsky/feed/defs'
import { countAll } from '../../../../db/util'

// THIS IS A TEMPORARY UNSPECCED ROUTE
export default function (server: Server, ctx: AppContext) {
Expand All @@ -21,25 +20,8 @@ export default function (server: Server, ctx: AppContext) {

const postsQb = feedService
.selectPostQb()
.leftJoin('repost', (join) =>
// this works well for one curating user. reassess if adding more
join
.on('repost.creator', '=', 'did:plc:ea2eqamjmtuo6f4rvhl3g6ne')
.onRef('repost.subject', '=', 'post.uri'),
)
.where((clause) =>
clause
.where('repost.creator', 'is not', null)
.orWhere(
(qb) =>
qb
.selectFrom('like')
.whereRef('like.subject', '=', 'post.uri')
.select(countAll.as('count')),
'>=',
5,
),
)
.leftJoin('post_agg', 'post_agg.uri', 'post.uri')
.where('post_agg.likeCount', '>=', 8)
.whereNotExists(
db
.selectFrom('mute')
Expand Down
26 changes: 26 additions & 0 deletions packages/pds/tests/views/popular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ describe('popular views', () => {
let dan: string
let eve: string
let frank: string
let george: string
let helen: string

const account = {
email: 'blah@test.com',
Expand All @@ -41,12 +43,27 @@ describe('popular views', () => {
handle: 'frank.test',
password: 'frank-pass',
})
await sc.createAccount('george', {
...account,
email: 'george@test.com',
handle: 'george.test',
password: 'george-pass',
})
await sc.createAccount('helen', {
...account,
email: 'helen@test.com',
handle: 'helen.test',
password: 'helen-pass',
})

alice = sc.dids.alice
bob = sc.dids.bob
carol = sc.dids.carol
dan = sc.dids.dan
eve = sc.dids.eve
frank = sc.dids.frank
george = sc.dids.george
helen = sc.dids.helen
await server.ctx.backgroundQueue.processAll()
})

Expand All @@ -61,23 +78,32 @@ describe('popular views', () => {
'image/jpeg',
)
const one = await sc.post(alice, 'first post', undefined, [img])
await sc.like(alice, one.ref)
await sc.like(bob, one.ref)
await sc.like(carol, one.ref)
await sc.like(dan, one.ref)
await sc.like(eve, one.ref)
await sc.like(frank, one.ref)
await sc.like(george, one.ref)
await sc.like(helen, one.ref)
const two = await sc.post(bob, 'bobby boi')
await sc.like(alice, two.ref)
await sc.like(bob, two.ref)
await sc.like(carol, two.ref)
await sc.like(dan, two.ref)
await sc.like(eve, two.ref)
await sc.like(frank, two.ref)
await sc.like(george, two.ref)
await sc.like(helen, two.ref)
const three = await sc.reply(bob, one.ref, one.ref, 'reply')
await sc.like(alice, three.ref)
await sc.like(bob, three.ref)
await sc.like(carol, three.ref)
await sc.like(dan, three.ref)
await sc.like(eve, three.ref)
await sc.like(frank, three.ref)
await sc.like(george, three.ref)
await sc.like(helen, three.ref)

const res = await agent.api.app.bsky.unspecced.getPopular(
{},
Expand Down