@@ -258,7 +258,8 @@ export async function getAllCardsAndModels(forceRefresh = false, currentDBId: nu
258258 }
259259
260260 const cardsForProcessing = finalCards ;
261- const processedCards = map ( cardsForProcessing , processCard ) ;
261+ // const processedCards = map(cardsForProcessing, processCard);
262+ const processedCards = cardsForProcessing . map ( processCard )
262263
263264 console . log ( 'Processed cards:' , processedCards ) ;
264265 const tables : Record < string , TableAndSchema > = { } ;
@@ -385,6 +386,31 @@ export async function getDatabaseTablesAndModelsWithoutFields(db_id: number, for
385386 } ;
386387}
387388
389+ export async function getDatabaseTablesModelsCardsWithoutFields ( db_id : number , forceRefreshModels : boolean = false , forceRefreshTables : boolean = false ) : Promise < DatabaseInfoWithTablesAndModels > {
390+ const tablesAndDetails = await getRelevantTablesAndDetailsForSelectedDb ( db_id , forceRefreshTables ) ;
391+ const cardsAndModels = await getAllCardsAndModels ( forceRefreshModels , db_id ) ;
392+ const allCardsAndModels = cardsAndModels . cards || [ ] ;
393+ const cards = allCardsAndModels . filter ( card => card . type == 'question' ) ;
394+ const models = allCardsAndModels . filter ( card => card . type !== 'question' ) ;
395+
396+ return {
397+ ...tablesAndDetails ,
398+ models : models . map ( ( model ) => ( {
399+ name : model . name ,
400+ collectionId : model . collection_id || null ,
401+ collectionName : get ( model . collection , 'name' , '' ) ,
402+ modelId : model . id ,
403+ description : model . description || undefined ,
404+ dbId : db_id
405+ } ) ) ,
406+ cards : cards . map ( card => ( {
407+ name : card . name ,
408+ id : card . id ,
409+ description : card . description ,
410+ } ) )
411+ } ;
412+ }
413+
388414export function handleEmpty < T > ( promise : Promise < T > , defaultValue : T ) : Promise < T > {
389415 return Promise . resolve ( promise ) . catch ( ( ) => defaultValue ) ;
390416}
0 commit comments