More realistic mock data

zio/stable
Paul Frazee 2022-07-20 11:07:07 -05:00
parent e78143b3dc
commit 8131158c0e
5 changed files with 234 additions and 80 deletions

View File

@ -15,7 +15,7 @@
"dependencies": {
"@adxp/auth": "*",
"@adxp/common": "*",
"@adxp/mock-api": "git+ssh://git@github.com:bluesky-social/adx-mock-api.git#74a1f810a342aa4b58a54724e21c57d2faa5e72e",
"@adxp/mock-api": "git+ssh://git@github.com:bluesky-social/adx-mock-api.git#3714722a09503caad6e3aba7f9e9027994d07bdb",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",

View File

@ -4,8 +4,10 @@
*/
// import {ReactNativeStore} from './auth'
import {AdxClient, AdxRepoClient} from '@adxp/mock-api'
import {AdxClient, AdxRepoClient, AdxUri, bsky} from '@adxp/mock-api'
import * as storage from './storage'
import {postTexts} from './mock-data/post-texts'
import {replyTexts} from './mock-data/reply-texts'
export async function setup(adx: AdxClient) {
await adx.setupMock(
@ -37,6 +39,14 @@ function repo(adx: AdxClient, didOrName: string) {
}
export async function generateMockData(adx: AdxClient) {
const rand = (n: number) => Math.floor(Math.random() * n)
const picka = <T>(arr: Array<T>): T => {
if (arr.length) {
return arr[rand(arr.length)] || arr[0]
}
throw new Error('Not found')
}
await adx.mockDb.addUser({name: 'alice.com', writable: true})
await adx.mockDb.addUser({name: 'bob.com', writable: true})
await adx.mockDb.addUser({name: 'carla.com', writable: true})
@ -44,6 +54,7 @@ export async function generateMockData(adx: AdxClient) {
const alice = repo(adx, 'alice.com')
const bob = repo(adx, 'bob.com')
const carla = repo(adx, 'carla.com')
const repos = [alice, bob, carla]
await alice.collection('blueskyweb.xyz:Profiles').put('Profile', 'profile', {
$type: 'blueskyweb.xyz:Profile',
@ -80,91 +91,63 @@ export async function generateMockData(adx: AdxClient) {
await follow(carla, 'alice.com')
await follow(carla, 'bob.com')
// 2 posts on each user
const alicePosts: {uri: string}[] = []
for (let i = 0; i < 2; i++) {
alicePosts.push(
await alice.collection('blueskyweb.xyz:Posts').create('Post', {
// a set of posts and reposts
const posts: {uri: string}[] = []
for (let i = 0; i < postTexts.length; i++) {
const author = picka(repos)
posts.push(
await author.collection('blueskyweb.xyz:Posts').create('Post', {
$type: 'blueskyweb.xyz:Post',
text: `Alice post ${i + 1}`,
text: postTexts[i],
createdAt: date.next().value,
}),
)
await bob.collection('blueskyweb.xyz:Posts').create('Post', {
$type: 'blueskyweb.xyz:Post',
text: `Bob post ${i + 1}`,
createdAt: date.next().value,
})
await carla.collection('blueskyweb.xyz:Posts').create('Post', {
$type: 'blueskyweb.xyz:Post',
text: `Carla post ${i + 1}`,
createdAt: date.next().value,
})
if (rand(10) === 0) {
await picka(repos)
.collection('blueskyweb.xyz:Posts')
.create('Repost', {
$type: 'blueskyweb.xyz:Repost',
subject: picka(posts).uri,
createdAt: date.next().value,
})
}
}
// small thread of replies on alice's first post
const bobReply1 = await bob
.collection('blueskyweb.xyz:Posts')
.create('Post', {
$type: 'blueskyweb.xyz:Post',
text: 'Bob reply',
reply: {root: alicePosts[0].uri, parent: alicePosts[0].uri},
createdAt: date.next().value,
})
await carla.collection('blueskyweb.xyz:Posts').create('Post', {
$type: 'blueskyweb.xyz:Post',
text: 'Carla reply',
reply: {root: alicePosts[0].uri, parent: alicePosts[0].uri},
createdAt: date.next().value,
})
const aliceReply1 = await alice
.collection('blueskyweb.xyz:Posts')
.create('Post', {
$type: 'blueskyweb.xyz:Post',
text: 'Alice reply',
reply: {root: alicePosts[0].uri, parent: bobReply1.uri},
createdAt: date.next().value,
})
// bob and carla repost alice's first post
await bob.collection('blueskyweb.xyz:Posts').create('Repost', {
$type: 'blueskyweb.xyz:Repost',
subject: alicePosts[0].uri,
createdAt: date.next().value,
})
await carla.collection('blueskyweb.xyz:Posts').create('Repost', {
$type: 'blueskyweb.xyz:Repost',
subject: alicePosts[0].uri,
createdAt: date.next().value,
})
// bob likes all of alice's posts
for (let i = 0; i < 2; i++) {
await bob.collection('blueskyweb.xyz:Likes').create('Like', {
$type: 'blueskyweb.xyz:Like',
subject: alicePosts[i].uri,
createdAt: date.next().value,
})
// a set of replies
for (let i = 0; i < 100; i++) {
const targetUri = picka(posts).uri
const urip = new AdxUri(targetUri)
const target = await adx.mainPds
.repo(urip.host, true)
.collection(urip.collection)
.get('Post', urip.recordKey)
const targetRecord = target.value as bsky.Post.Record
const author = picka(repos)
posts.push(
await author.collection('blueskyweb.xyz:Posts').create('Post', {
$type: 'blueskyweb.xyz:Post',
text: picka(replyTexts),
reply: {
root: targetRecord.reply ? targetRecord.reply.root : target.uri,
parent: target.uri,
},
createdAt: date.next().value,
}),
)
}
// carla likes all of alice's posts and everybody's replies
for (let i = 0; i < 2; i++) {
await carla.collection('blueskyweb.xyz:Likes').create('Like', {
$type: 'blueskyweb.xyz:Like',
subject: alicePosts[i].uri,
createdAt: date.next().value,
})
// a set of likes
for (const post of posts) {
for (const repo of repos) {
if (rand(3) === 0) {
await repo.collection('blueskyweb.xyz:Likes').create('Like', {
$type: 'blueskyweb.xyz:Like',
subject: post.uri,
createdAt: date.next().value,
})
}
}
}
await carla.collection('blueskyweb.xyz:Likes').create('Like', {
$type: 'blueskyweb.xyz:Like',
subject: aliceReply1.uri,
createdAt: date.next().value,
})
await carla.collection('blueskyweb.xyz:Likes').create('Like', {
$type: 'blueskyweb.xyz:Like',
subject: bobReply1.uri,
createdAt: date.next().value,
})
// give alice 3 badges, 2 from bob and 2 from carla, with one ignored
const inviteBadge = await bob

View File

@ -0,0 +1,147 @@
// I just scraped some of my twitter timeline into here
// hope nobody minds
// -prf
export const postTexts = [
'last call! share your most offbeat home idea and you could get $100,000 USD to build it. applications to the OMG! fund are open until july 22. for rules and how to apply→ http://airbnb.com/omgfund?twclid=2-6f25jsvulsw1bpglil5jvkku0',
'Great to get some quality time with @DavidJWest #Agile2022',
'vive la sybil résistance',
'Where does one mint on @tezos these days?',
'Tame the day with the soothing and luxurious all-new 2022 INFINITI QX60.',
"In case you're wondering how it's going in the UK, here's the person most likely to be our next PM:",
'Really thought I was watching an SNL clip',
'Mediocrity is like a magnet pulling organizations toward it. You can only avoid it by constant effort.',
'Nobody in the replies talking about RegCF, DAOs, etc…\n' +
'\n' +
'The innovation is non, perhaps contra-hierarchical.',
'There are times when I think DevOps is just group therapy for system administrators.',
'Is DevOps still relevant?\n' +
'\n' +
'Join me tomorrow, at 11:00 AM PDT, to discuss the state of DevOps with @nathenharvey, as we attempt to answer that question. https://twitter.com/i/spaces/1dRKZlMPbWaJB…',
'trash is love. trash is life.',
'I want you guys to know Ive done it. Ive killed the legendary Michael Myers with a series of good stabs. No one could survive it. Hell, I even checked to be sure he was dead. Anyone got weekend plans?',
'Orgs that performed timely server upgrades averaged 19% revenue growth.',
'Seeing all of the @ mention mint scams of late…',
"For fuck's sake, Gary.",
'And another',
'Ah go on, one more',
"Wait, so there's no way to test microphone settings for Twitter Spaces without creating a Twitter Space, going 'live', and having it notify everyone? Amazing.",
'gidge day',
'British Defense Intelligence Ukraine Update, July 20, 2022\n' +
'#RussiaUkraineWar',
' Were launching a brand new template soon on @tailwindui Im really excited about this one! \n' +
'\n' +
'Here is a preview:',
'Are you looking for a pediatrician near your home or work? ARC has pediatricians in 23 locations around Central Texas. \n' +
'\n' +
'Our pediatricians are ready to partner with you in the growth and development of your child and family, no matter where you live.',
'And well be making undici-fetch happen. H/t @matteocollina',
"It's Wednesday, you know what that means....\n" +
'\n' +
' Office Hours - 9:30AM PDT / 12:30PM EDT / 4:30PM (16:30) GMT \n' +
'\n' +
' Maker Hour - 1:00PM PDT / 4:00PM EDT / 8:00PM (20:00) GMT\n' +
'\n' +
'Join us in @discord',
"Europe's bleak Russian winter, made stark: \n" +
'\n' +
"Brussels proposes Europe cuts its gas usage by 15 per cent between now and April next year if governments literally want to keep the lights on and people's homes warm.",
'Tips for using TypeScript via JSDoc comments',
'My talk is today come say hi!',
'Im giving a talk on private smart contract using homomorphic encryption on Wednesday at 2:20pm. Come say hi! #fhe #web3 #privacy #ethereum',
'We have just showcased the new build and discussed our future plans to support developers Recording coming soon! If you are in Paris drop us a line to grab a coffee ',
'TFW you forget to buy milk for your morning coffee and now have to get dressed and go outside at 6:30am.',
'seeing an awful lot of articles referring to the "European heatwave" in the past tense. first of all:',
'Is there a way to fix this issue this when using TypeScript via JSDoc comments? (Reply to the quoted tweet.)',
'For instance in this code I dont know how to tell TS that, no, the `res` will not be `string`. (`api` is an instance of the `got` npm package).',
'In the latest magazine, bob kindly invited me to write about techniques for ensuring convergence in distributed systems. Article is now up!',
"This is a reboot of the “Research for Practice” column that @alice.com used to run. The idea is to distill some key ideas from recent CS research and to make them accessible to folks in industry who don't normally have time for reading papers.",
"This is cool: post a video to @whimful's REVERSE CONFERENCE @ DWeb so you can maximize your human connecting time at camp ",
'New blog post: How to speed up the Rust compiler in July 2022\n' +
'\n' +
'https://nnethercote.github.io/2022/07/20/how-to-speed-up-the-rust-compiler-in-july-2022.html…\n' +
'\n' +
'PGO on Windows, MIR inlining, better derived code for builtin traits, and much more!',
'my new favorite past time is watching older couples at the airport \n' +
'\n' +
'Wife: “Put your mask on. I dont want you sick for your birthday.”\n' +
'Husband: “Can you leave me alone for one goddamn minute?”',
"We're all gonna die",
'Builders building, this month at @NativeHostels on 4th Street.\n' +
'- Coworking & coffee on Tuesdays 11am-3pm \n' +
'- HAPPY HOUR HANGOUTS on Thursdays 7:30-10pm \n' +
'RSVP: https://ATXDAO-Native-HH.eventbrite.com',
'crypto meetings IRL are my favorite.\n' +
'\n' +
'@ATXDAO\n' +
'@HopeCampaign\n' +
'@NativeHostels\n' +
'@wagmiyall \n' +
'@evrydayresearch \n' +
'@zcreativemedia \n' +
'@CrystalGravy2\n' +
'@NickCPlusPlus\n' +
'@_ElaineAlonzo',
'I recommend @Scroll_ZKP create and hire for a developer advocate position to deliver world class developer experience.',
'Intelligent Tracking Prevention identifies trackers and helps prevent them from profiling or following you across the web.',
"Big story in Norway this summer is a walrus we've named Freya has made it to our shores and is touring the country, laying around and sinking boats",
'"the other fellows at the CIA were unequivocally against assassinating three of the greatest musicians of their generation, but I went in there and held my convictions and said my piece."',
'hls is annoying technology',
'This summer, prey for survival. Experience #BeastMovie only in theaters August 19.',
"got the new twitter update. i don't like it",
'Might just set this as a daily reminder.',
'Gm. Today, ask yourself:\n' +
'\n' +
'Is my Web3/NFT/DeFi/crypto making a better life for someone other than myself?',
'every time I add a piece to my native #webgl engine I end up crying and appreciating even more the work @mrdoob and the @threejs team is doing. yall have no idea',
'i dont like having 2 plagues and no healthcare. i should have 0 plagues and 2 healthcare',
'this is the only lotr behind the scenes pic that matters actually',
'Photographer took pictures of a baby hippo scared of birds',
'lol',
"VC's explaining web3.",
'Cyberattacks cost banks $18.3 million annually per company. We ensure that youre not part of that statistic.#stayrelentless.',
'In SF, you can choose kind of weather you want',
'a day in earth 2.0 should be 26 hours',
'who wants to start a religion',
'We just launched our code-hosting platform!\n' +
'\n' +
"It's like Github, but has hyperlinked syntax-highlighted code and docs from day one \n" +
'\n' +
"I can't overemphasize how nice it feels to push code and immediately see it there, published, highlighted, and linked up!",
'Now that youve seen them do the universe, its time for them to do a new series. Mike Judges Beavis and Butt-Head is coming to #ParamountPlus on August 4th. #beavisandbutthead',
'Organized a nice crypto research dinner with @protocollabs and @zama_fhe - very vibrant community with a lot of open problems :)\n' +
'\n' +
'Planning to organize more going forward - reach out if this is your vibe!',
"Houston drivers are crazy. Been here two days and have had multiple vehicles charging up and tailing me, then switching lanes, roaring past, and weaving through traffic. While I'm going 75mph, keeping with the flow of traffic. WTF??",
`LIVE NOW: a mix of projects coming to #DWebCamp2022! @gvelez17 of @dsocialcommons is planning "Dogfooding Decentralization" a user-testing lab at DWeb Camp. You can sign up to present your tools. We'll send you the link tomorrow! 1/n`,
`Fabiola of @guardianproject is bringing "Butter Box" "Inspiration Beans" & more. (They must love ) Butter Box is raspberry pi-based hotspot w/ encrypted chat. It's opensource & offline first. Come onboard & connect with others offline. (8/n)`,
"Up Now: @guardianproject's Jack Fox Keen w/ tools to verify the authencity++ of data. They are leading a Cryptographically Verified Scavenger Hunt (9/n)",
'Translating VC Language',
'What would Sherlock Holmes do? Listen to true crime podcasts early on Amazon Music. #TrueCrimeonAmazonMusic',
'How to deal with a hung Linux system',
'ALRIGHT PELOTON HAPPY MONDAY I WANNA FEEL THAT ENERGY COMING THROUGH THE SCREEN AS WE START GETTING OUR AMAZING BODIES WARMED UP. THIS FIRST TRACK IS CALLED "DONALD DUCK GETTING A BLOWJOB" RESISTANCE 30 CADENCE 80',
"Thank you to all who joined us at @pbailis' executive roundtable lunch at @VentureBeat's #VBTransform!\n" +
'\n' +
'#ICYMI, stop by the Sisu table today to meet the team & learn how to supercharge your analytics workflow with decision intelligence.',
'Prescribing Info: http://bit.ly/2cTmItE?twclid=2-1jogj2v7zxu2rw1zmzyms8jpg \n' +
'Med Guide: http://bit.ly/2yon94P?twclid=2-1jogj2v7zxu2rw1zmzyms8jpg\n' +
'\n' +
'Discover a treatment for certain patients with kidney cancer (RCC).',
'Want to learn how to write E2EE P2P apps without even trying? Check out the new application sandbox and api in Peergos!',
'Ageism was always a reality in tech. \n' +
'\n' +
'The “in-office” only crowd have found a way to make their ageism more respectable.\n' +
'\n' +
'PS - most startups would rather hire the 32 yo Senior FAANG engineer than a 20 something grad who needs a ton of mentorship.',
"I don't mind jumping on a call at work. I think that should be the last resort, not the first one.",
'If you missed attending #MSInspire, we missed you too. You can still find plenty of on-demand content available at your convenience. Take advantage of the ongoing opportunity to enrich your business prospects.',
"TODAY AT 4 PM PT: Join for the DWeb Meetup where we'll see some of the workshops coming to DWeb Camp 2022:\n" +
'@metagov_project\n' +
' @ameliawb\n' +
' @guardianproject\n' +
' @gvelez17\n' +
' @infrared_ether\n' +
'@LauBenedict\n' +
' @guardianproject\n' +
'@byUnfinished\n' +
' Come be inspired:',
]

View File

@ -0,0 +1,24 @@
export const replyTexts = [
'Wow, so true!',
'Haha ikr',
'lol',
'What does this mean for democrats in the midterms?',
'What does this mean for republicans in the midterms?',
'What does this mean for pet owners in the midterms?',
'is it cool if I DM?',
"This is sort of accurate, but honestly it misses a huge part of the issue at hand. There are just so many factors and I don't think a vibe is enough to cover it.",
'Wen token',
'This is disgusting and you should take it down',
'fire',
'a/s/l?',
'this is so much better than twitter',
'this is so much better than tiktok',
'this is so much better than gab',
'this is so much better than truth social',
'finally! decentralization!',
'ugh when will hashtags get supported in vibe',
'ted cruz is the deep state!',
'aoc is the deep state!',
'donald trump is the deep state!',
'taco tuesdays is the deep state!',
]

View File

@ -55,9 +55,9 @@
ucans "0.9.0-alpha3"
uint8arrays "^3.0.0"
"@adxp/mock-api@git+ssh://git@github.com:bluesky-social/adx-mock-api.git#74a1f810a342aa4b58a54724e21c57d2faa5e72e":
"@adxp/mock-api@git+ssh://git@github.com:bluesky-social/adx-mock-api.git#3714722a09503caad6e3aba7f9e9027994d07bdb":
version "0.0.1"
resolved "git+ssh://git@github.com:bluesky-social/adx-mock-api.git#74a1f810a342aa4b58a54724e21c57d2faa5e72e"
resolved "git+ssh://git@github.com:bluesky-social/adx-mock-api.git#3714722a09503caad6e3aba7f9e9027994d07bdb"
dependencies:
ajv "^8.11.0"
ajv-formats "^2.1.1"