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

Function cleanUp

packages/queue/src/tasks/remove-community.ts:39–127  ·  view source on GitHub ↗
({
  accountId,
  logger,
}: {
  accountId: string;
  logger: Logger;
})

Source from the content-addressed store, hash-verified

37}
38
39async function cleanUp({
40 accountId,
41 logger,
42}: {
43 accountId: string;
44 logger: Logger;
45}) {
46 const channels = await prisma.channels.findMany({
47 select: { id: true, channelName: true },
48 where: { accountId },
49 });
50
51 for (const channel of channels) {
52 logger.info({ channel });
53 logger.setPrefix(channel.channelName);
54
55 const mentionsCount = await prisma.mentions.deleteMany({
56 where: { messages: { channelId: channel.id } },
57 });
58 logger.info({ mentionsCount });
59 const attachments = await prisma.messageAttachments.findMany({
60 where: { messages: { channelId: channel.id } },
61 });
62 logger.info({ attachmentsCount: attachments.length });
63 await processAttachments({ attachments, logger });
64
65 const messageCount = await prisma.messages.deleteMany({
66 where: { channelId: channel.id },
67 });
68 logger.info({ messageCount });
69 const threadCount = await prisma.threads.deleteMany({
70 where: { channel: { id: channel.id } },
71 });
72 logger.info({ threadCount });
73
74 const channelMembershipCount = await prisma.memberships.deleteMany({
75 where: { channelsId: channel.id },
76 });
77 logger.info({ channelMembershipCount });
78
79 const channelIntegrationsCount =
80 await prisma.channelsIntegration.deleteMany({
81 where: { channelId: channel.id },
82 });
83 logger.info({ channelIntegrationsCount });
84
85 await prisma.channels.delete({
86 where: { id: channel.id },
87 });
88 }
89 logger.cleanPrefix();
90 logger.info({ channelsCount: channels.length });
91
92 const invitesCount = await prisma.invites.deleteMany({
93 where: { accountsId: accountId },
94 });
95 logger.info({ invitesCount });
96

Callers 2

taskFunction · 0.70

Calls 5

processAttachmentsFunction · 0.70
infoMethod · 0.65
setPrefixMethod · 0.65
cleanPrefixMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected