@@ -821,6 +821,39 @@ def get_all_generate_metadata(self) -> List[Dict]:
821821 print (f"Error retrieving all metadata: { str (e )} " )
822822 return []
823823
824+ def get_paginated_generate_metadata_light (self , page : int , page_size : int ) -> Tuple [int , List [Dict ]]:
825+ """Retrieve paginated metadata with only fields needed for list view"""
826+ try :
827+ with self .get_connection () as conn :
828+ conn .row_factory = sqlite3 .Row
829+ cursor = conn .cursor ()
830+
831+ # Get total count
832+ count_query = "SELECT COUNT(*) FROM generation_metadata"
833+ cursor .execute (count_query )
834+ total_count = cursor .fetchone ()[0 ]
835+
836+ # Get only fields needed for list view
837+ offset = (page - 1 ) * page_size
838+ query = """
839+ SELECT
840+ id, timestamp, display_name, generate_file_name, model_id,
841+ num_questions, total_count, use_case, job_status,
842+ local_export_path, hf_export_path, completed_rows
843+ FROM generation_metadata
844+ ORDER BY timestamp DESC
845+ LIMIT ? OFFSET ?
846+ """
847+ cursor .execute (query , (page_size , offset ))
848+
849+ results = [dict (row ) for row in cursor .fetchall ()]
850+ return total_count , results
851+
852+ except Exception as e :
853+ print (f"Error retrieving paginated metadata: { str (e )} " )
854+ return 0 , []
855+
856+
824857 def get_paginated_generate_metadata (self , page : int , page_size : int ) -> Tuple [int , List [Dict ]]:
825858 """Retrieve paginated metadata entries for generations"""
826859 try :
0 commit comments