(keys: any)
| 5 | import { getErrorMessage } from '../errors/utils' |
| 6 | |
| 7 | export 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 | } |
no test coverage detected