MCPcopy Create free account
hub / github.com/dailydotdev/apps / fetchWorld

Function fetchWorld

packages/world-cli/src/world.js:50–70  ·  view source on GitHub ↗
(handle, { api })

Source from the content-addressed store, hash-verified

48}
49
50export async function fetchWorld(handle, { api }) {
51 /* `user` takes a handle, `userWorld` takes the id it resolves to: the world
52 tables are keyed on userId, so passing the handle straight through returns
53 an empty world rather than an error, which reads exactly like a private one. */
54 const user = (await gql(api, USER, { id: handle }))?.user;
55 if (!user) throw new Error(`No daily.dev user called "${handle}".`);
56 const world = await gql(api, WORLD, { id: user.id });
57
58 const raw = world.userWorld ?? [];
59 const districts = raw
60 .map(({ reads, niche }) => ({
61 niche: niche.slug,
62 topic: niche.title,
63 reads,
64 level: levelOf(reads),
65 }))
66 .filter((d) => d.level > 0)
67 .sort((a, b) => b.reads - a.reads);
68
69 return { user, districts };
70}

Callers 3

resolveTargetFunction · 0.90
runInspectFunction · 0.90
runDevFunction · 0.90

Calls 2

gqlFunction · 0.85
levelOfFunction · 0.70

Tested by

no test coverage detected