File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
packages/backend/src/graphql/queries/tiles Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import getTables from './get-tables'
66
77interface ExtendedFlow extends Flow {
88 tableid : string
9+ count : number
910}
1011
1112interface TableConnection {
@@ -29,16 +30,18 @@ const getTableConnections: QueryResolvers['getTableConnections'] = async (
2930 // get distinct rows of tables used in flows
3031 // returns flow id and table id
3132 const distinctTableFlows = await Flow . query ( )
32- . distinct ( 'flows.id' , Flow . raw ( "steps.parameters ->> 'tableId' AS tableId" ) )
33+ . select ( Flow . raw ( "steps.parameters ->> 'tableId' AS tableid" ) )
34+ . countDistinct ( 'flows.id' )
3335 . innerJoinRelated ( 'steps' )
3436 . innerJoinRelated ( 'user' )
3537 . where ( 'steps.app_key' , 'tiles' )
3638 . whereRaw ( "steps.parameters ->> 'tableId' IS NOT NULL" )
3739 . whereRaw ( `steps.parameters ->> 'tableId' IN (${ tableIdStr } )` )
40+ . groupByRaw ( "steps.parameters ->> 'tableId'" )
3841
3942 const result = distinctTableFlows . reduce (
40- ( acc : TableConnection , obj : ExtendedFlow ) => {
41- acc [ obj . tableid ] = ( acc [ obj . tableid ] || 0 ) + 1
43+ ( acc : TableConnection , row : ExtendedFlow ) => {
44+ acc [ row . tableid ] = row . count
4245 return acc
4346 } ,
4447 { } ,
You can’t perform that action at this time.
0 commit comments