MCPcopy
hub / github.com/FlowiseAI/Flowise / addChatflowsCount

Function addChatflowsCount

packages/server/src/utils/addChatflowsCount.ts:7–37  ·  view source on GitHub ↗
(keys: any)

Source from the content-addressed store, hash-verified

5import { getErrorMessage } from '../errors/utils'
6
7export const addChatflowsCount = async (keys: any) => {
8 try {
9 const appServer = getRunningExpressApp()
10 let tmpResult = keys
11 if (typeof keys !== 'undefined' && keys.length > 0) {
12 const updatedKeys: any[] = []
13 //iterate through keys and get chatflows
14 for (const key of keys) {
15 const chatflows = await appServer.AppDataSource.getRepository(ChatFlow)
16 .createQueryBuilder('cf')
17 .where('cf.apikeyid = :apikeyid', { apikeyid: key.id })
18 .andWhere('cf.workspaceId = :workspaceId', { workspaceId: key.workspaceId })
19 .getMany()
20 const linkedChatFlows: any[] = []
21 chatflows.map((cf) => {
22 linkedChatFlows.push({
23 flowName: cf.name,
24 category: cf.category,
25 updatedDate: cf.updatedDate
26 })
27 })
28 key.chatFlows = linkedChatFlows
29 updatedKeys.push(key)
30 }
31 tmpResult = updatedKeys
32 }
33 return tmpResult
34 } catch (error) {
35 throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Error: addChatflowsCount - ${getErrorMessage(error)}`)
36 }
37}

Callers 1

getAllApiKeysFunction · 0.90

Calls 2

getRunningExpressAppFunction · 0.90
getErrorMessageFunction · 0.90

Tested by

no test coverage detected