MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / index

Function index

apps/web/pages/api/all/index.tsx:18–95  ·  view source on GitHub ↗
({
  params,
}: {
  params: {
    communityName?: string;
    page?: number;
    limit?: number;
    channelIds?: string[];
  };
})

Source from the content-addressed store, hash-verified

16}
17
18export async function index({
19 params,
20}: {
21 params: {
22 communityName?: string;
23 page?: number;
24 limit?: number;
25 channelIds?: string[];
26 };
27}) {
28 const community = await CommunityService.find(params);
29 if (!community) {
30 return { status: 404 };
31 }
32
33 const page = getPage(params.page);
34 const channels = await ChannelsService.findPublic(community.id);
35
36 if (!params.limit) {
37 return { status: 400 };
38 }
39
40 const limit = Number(params.limit);
41
42 const condition = {
43 hidden: false,
44 messages: {
45 some: {},
46 },
47 lastReplyAt: { not: null },
48 channelId: { in: channels.map(({ id }) => id) },
49 } as any;
50
51 const threads = await prisma.threads.findMany({
52 where: condition,
53 include: {
54 messages: {
55 include: {
56 author: true,
57 mentions: {
58 include: {
59 users: true,
60 },
61 },
62 reactions: true,
63 attachments: true,
64 },
65 orderBy: { sentAt: 'asc' },
66 },
67 channel: true,
68 },
69 orderBy: { lastReplyAt: 'desc' },
70 take: limit,
71 skip: (page - 1) * limit,
72 });
73
74 const total = await prisma.threads.count({
75 where: condition,

Callers

nothing calls this directly

Calls 7

anonymizeMessagesFunction · 0.90
findPublicMethod · 0.80
mapMethod · 0.80
getPageFunction · 0.70
logMethod · 0.65
findMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected