MCPcopy Index your code
hub / github.com/chartbrew/chartbrew / deleteUser

Method deleteUser

server/controllers/UserController.js:92–277  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

90 }
91
92 async deleteUser(id) {
93 const transaction = await db.sequelize.transaction();
94 const cleanupConversations = async (where) => {
95 const conversations = await db.AiConversation.findAll({
96 attributes: ["id"],
97 where,
98 transaction
99 });
100
101 if (conversations.length < 1) {
102 return;
103 }
104
105 const conversationIds = conversations.map((conversation) => conversation.id);
106
107 await Promise.all([
108 db.AiMessage.destroy({
109 where: { conversation_id: { [Op.in]: conversationIds } },
110 transaction
111 }),
112 db.AiUsage.update(
113 { conversation_id: null },
114 {
115 where: { conversation_id: { [Op.in]: conversationIds } },
116 transaction
117 }
118 )
119 ]);
120
121 await db.AiConversation.destroy({
122 where: { id: { [Op.in]: conversationIds } },
123 transaction
124 });
125 };
126
127 try {
128 await cleanupConversations({ user_id: id });
129
130 await Promise.all([
131 db.SavedQuery.destroy({
132 where: { "user_id": id },
133 transaction
134 }),
135 db.ChartCache.destroy({
136 where: { "user_id": id },
137 transaction
138 }),
139 db.User2fa.destroy({
140 where: { "user_id": id },
141 transaction
142 }),
143 db.PinnedDashboard.destroy({
144 where: { "user_id": id },
145 transaction
146 }),
147 db.ProjectRole.destroy({
148 where: { "user_id": id },
149 transaction

Callers 1

UserRoute.jsFile · 0.80

Calls 2

filterMethod · 0.80
findAllMethod · 0.45

Tested by

no test coverage detected