forked from bluesky-social/atproto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build timeline and author feeds from feed items index (bluesky-social…
…#774) * Index posts and reposts into feed_item table for building feeds * Use feed_item table for building timeline and author feeds * Apply feed item indexing to bsky app view * Fix bsky appview tests, test getPopular * Use feed item index to build feeds in bsky app view
- Loading branch information
Showing
20 changed files
with
709 additions
and
630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import AtpAgent from '@atproto/api' | ||
import { runTestServer, CloseFn, processAll, TestServerInfo } from '../_util' | ||
import { SeedClient } from '../seeds/client' | ||
import basicSeed from '../seeds/basic' | ||
|
||
describe('popular views', () => { | ||
let server: TestServerInfo | ||
let agent: AtpAgent | ||
let close: CloseFn | ||
let sc: SeedClient | ||
|
||
// account dids, for convenience | ||
let alice: string | ||
let bob: string | ||
let carol: string | ||
let dan: string | ||
let eve: string | ||
let frank: string | ||
|
||
const account = { | ||
email: '[email protected]', | ||
password: 'blh-pass', | ||
} | ||
|
||
beforeAll(async () => { | ||
server = await runTestServer({ | ||
dbPostgresSchema: 'views_popular', | ||
}) | ||
close = server.close | ||
agent = new AtpAgent({ service: server.url }) | ||
const pdsAgent = new AtpAgent({ service: server.pdsUrl }) | ||
sc = new SeedClient(pdsAgent) | ||
await basicSeed(sc) | ||
await sc.createAccount('eve', { | ||
...account, | ||
email: '[email protected]', | ||
handle: 'eve.test', | ||
password: 'eve-pass', | ||
}) | ||
await sc.createAccount('frank', { | ||
...account, | ||
email: '[email protected]', | ||
handle: 'frank.test', | ||
password: 'frank-pass', | ||
}) | ||
await processAll(server) | ||
alice = sc.dids.alice | ||
bob = sc.dids.bob | ||
carol = sc.dids.carol | ||
dan = sc.dids.dan | ||
eve = sc.dids.eve | ||
frank = sc.dids.frank | ||
}) | ||
|
||
afterAll(async () => { | ||
await close() | ||
}) | ||
|
||
it('returns well liked posts', async () => { | ||
const img = await sc.uploadFile( | ||
alice, | ||
'tests/image/fixtures/key-landscape-small.jpg', | ||
'image/jpeg', | ||
) | ||
const one = await sc.post(alice, 'first post', undefined, [img]) | ||
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) | ||
const two = await sc.post(bob, 'bobby boi') | ||
await sc.like(alice, 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) | ||
const three = await sc.reply(bob, one.ref, one.ref, 'reply') | ||
await sc.like(alice, 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 processAll(server) | ||
|
||
const res = await agent.api.app.bsky.unspecced.getPopular( | ||
{}, | ||
{ headers: sc.getHeaders(alice, true) }, | ||
) | ||
const feedUris = res.data.feed.map((i) => i.post.uri).sort() | ||
const expected = [one.ref.uriStr, two.ref.uriStr, three.ref.uriStr].sort() | ||
expect(feedUris).toEqual(expected) | ||
}) | ||
}) |
Oops, something went wrong.