@@ -31,7 +31,16 @@ def add_project_name_to_time_entries(time_entries, projects):
31
31
setattr (time_entry , 'project_name' , project .name )
32
32
33
33
34
- def create_in_condition (data_object , attr_to_filter = "" , first_attr = "c.id" ):
34
+ def create_in_condition (
35
+ data_object : list , attr_to_filter : str = "" , first_attr : str = "c.id"
36
+ ):
37
+ """
38
+ Function to create a custom query string from a list of objects or a list of strings.
39
+ :param data_object: List of objects or a list of strings
40
+ :param attr_to_filter: Attribute to retrieve the value of the objects (Only in case it is a list of objects)
41
+ :param first_attr: First attribute to build the condition
42
+ :return: Custom condition string
43
+ """
35
44
attr_filter = re .sub ('[^a-zA-Z_$0-9]' , '' , attr_to_filter )
36
45
object_id = (
37
46
[str (i ) for i in data_object ]
@@ -49,6 +58,13 @@ def create_in_condition(data_object, attr_to_filter="", first_attr="c.id"):
49
58
def create_custom_query_from_str (
50
59
data : str , first_attr , delimiter : str = ","
51
60
) -> str :
61
+ """
62
+ Function to create a string condition for url parameters (Example: data?values=value1,value2 or data?values=*)
63
+ :param data: String to build the query
64
+ :param first_attr: First attribute to build the condition
65
+ :param delimiter: String delimiter
66
+ :return: Custom condition string
67
+ """
52
68
data = data .split (delimiter )
53
69
if len (data ) > 1 :
54
70
query_str = create_in_condition (data , first_attr = first_attr )
0 commit comments