@@ -74,7 +74,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
7474 def __enter__ (self ):
7575 return self
7676
77- def get_table_names (self ):
77+ def get_table_names (self ) -> list [ str ] :
7878 """
7979 Returns a list of all user-defined tables in the database.
8080
@@ -87,7 +87,13 @@ def get_table_names(self):
8787 cursor .close ()
8888 return tables
8989
90- def get_column_values (self , * columns : str , from_table : str ):
90+ def get_column_values (self , * columns : str , from_table : str ) -> list [tuple ]:
91+ """
92+ Returns the values of the specified columns from the specified table.
93+ :param columns: list of column names
94+ :param from_table: name of the table
95+ :return: list of tuples containing the values of the specified columns
96+ """
9197 cursor = self .conn .execute (f"SELECT { ', ' .join (columns )} FROM { from_table } " )
9298 return cursor .fetchall ()
9399
@@ -116,6 +122,11 @@ def count_all_entries(self, from_table: str) -> int:
116122 return count
117123
118124 def count_notnull_entries (self , * columns : str , from_table : str ) -> int :
125+ """
126+ Count the number of non-null entries in the specified columns of the specified table.
127+ :param columns: list of column names
128+ :param from_table: name of the table
129+ """
119130 count = self .conn .execute (
120131 f"SELECT COUNT(*) FROM { from_table } WHERE { ' AND ' .join ([column + ' IS NOT NULL' for column in columns ])} "
121132 ).fetchone ()[0 ]
@@ -135,6 +146,9 @@ def has_column(self, column_name: str, table_name: str) -> bool:
135146 return column_name in columns
136147
137148 def get_null_entries (self , from_table : str ) -> list :
149+ """
150+ Returns values (id and summary) witch has null values in its embedding column.
151+ """
138152 cursor = self .conn .execute (
139153 f"SELECT id, summary FROM { from_table } WHERE embedding IS NULL"
140154 )
@@ -174,8 +188,8 @@ def join_all_tables_by_requirements(
174188 self , where_clauses = "" , params = None
175189 ) -> list [tuple ]:
176190 """
177- Join all tables related to requirements based on the provided where clauses and parameters.
178- return a list of tuples containing :
191+ Extract values from requirements with related annotations and their test cases based on the provided where clauses and parameters.
192+ Return a list of tuples containing :
179193 req_id,
180194 req_external_id,
181195 req_summary,
@@ -222,6 +236,14 @@ def join_all_tables_by_requirements(
222236 def get_ordered_values_from_requirements (
223237 self , distance_sql = "" , where_clauses = "" , distance_order_sql = "" , params = None
224238 ) -> list [tuple ]:
239+ """
240+ Extracted values from Requirements table based on the provided where clauses and specified parameters ordered by distance and id.
241+ Return a list of tuples containing :
242+ req_id,
243+ req_external_id,
244+ req_summary,
245+ distance between annotation and requirement embeddings,
246+ """
225247 where_sql = f"WHERE { ' AND ' .join (where_clauses )} " if where_clauses else ""
226248 sql = f"""
227249 SELECT
@@ -241,6 +263,14 @@ def get_ordered_values_from_requirements(
241263 def get_ordered_values_from_test_cases (
242264 self , distance_sql = "" , where_clauses = "" , distance_order_sql = "" , params = None
243265 ) -> list [tuple ]:
266+ """
267+ Extracted values from TestCases table based on the provided where clauses and specified parameters ordered by distance and id.
268+ Return a list of tuples containing :
269+ case_id,
270+ test_script,
271+ test_case,
272+ distance between test case and typed by user text embeddings if it is specified,
273+ """
244274 where_sql = f"WHERE { ' AND ' .join (where_clauses )} " if where_clauses else ""
245275 sql = f"""
246276 SELECT
@@ -260,6 +290,21 @@ def get_ordered_values_from_test_cases(
260290 def join_all_tables_by_test_cases (
261291 self , where_clauses = "" , params = None
262292 ) -> list [tuple ]:
293+ """
294+ Join all tables related to test cases based on the provided where clauses and specified parameters.
295+ Return a list of tuples containing :
296+ case_id,
297+ test_script,
298+ test_case,
299+ anno_id,
300+ anno_summary,
301+ anno_embedding,
302+ distance between annotation and requirement embeddings,
303+ req_id,
304+ req_external_id,
305+ req_summary,
306+ req_embedding
307+ """
263308 where_sql = ""
264309 if where_clauses :
265310 where_sql = f"WHERE { ' AND ' .join (where_clauses )} "
@@ -294,7 +339,10 @@ def join_all_tables_by_test_cases(
294339 data = self .conn .execute (sql , params )
295340 return data .fetchall ()
296341
297- def get_embeddings_by_id (self , id1 : int , from_table : str ):
342+ def get_embeddings_by_id (self , id1 : int , from_table : str ) -> float :
343+ """
344+ Returns the embedding of the specified id from the specified table.
345+ """
298346 cursor = self .conn .execute (
299347 f"SELECT embedding FROM { from_table } WHERE id = ?" , (id1 ,)
300348 )
0 commit comments