Skip to content

Commit c80d2a4

Browse files
committed
feat: Add documentation to util functions
1 parent 6505560 commit c80d2a4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

utils/extend_model.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ def add_project_name_to_time_entries(time_entries, projects):
3131
setattr(time_entry, 'project_name', project.name)
3232

3333

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+
"""
3544
attr_filter = re.sub('[^a-zA-Z_$0-9]', '', attr_to_filter)
3645
object_id = (
3746
[str(i) for i in data_object]
@@ -49,6 +58,13 @@ def create_in_condition(data_object, attr_to_filter="", first_attr="c.id"):
4958
def create_custom_query_from_str(
5059
data: str, first_attr, delimiter: str = ","
5160
) -> 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+
"""
5268
data = data.split(delimiter)
5369
if len(data) > 1:
5470
query_str = create_in_condition(data, first_attr=first_attr)

0 commit comments

Comments
 (0)