File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
apps/src/metabase/helpers Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -49,16 +49,9 @@ export async function getSelectedDbId(): Promise<number | undefined> {
4949 let dbId ;
5050
5151 if ( isDashboard ) {
52- // const dashcards = await getMetabaseState('dashboard.dashcards') as any;
53- // const dbIds = Object.values(dashcards || []).map((d: any) => d.card.database_id);
54- // this is deprecated in new Metabase versions
55-
56- const dashcards = await getMetabaseState ( 'dashboard.dashcardData' ) as any ;
57- const dbIds = Object . keys ( dashcards ) . map ( cardId => {
58- return Object . keys ( dashcards [ cardId ] ) . map ( key => {
59- return dashcards [ cardId ] [ key ] ?. database_id ;
60- } ) ;
61- } ) ;
52+ const dashcards = await getMetabaseState ( 'dashboard.dashcards' ) as any ;
53+ const dbIds = Object . values ( dashcards || [ ] ) . map ( ( d : any ) => d . card . database_id ) ;
54+
6255 dbId = _ . chain ( dbIds ) . countBy ( ) . toPairs ( ) . maxBy ( _ . last ) . head ( ) . value ( ) ;
6356 try {
6457 dbId = parseInt ( dbId ) ;
You can’t perform that action at this time.
0 commit comments