MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / list_objects

Function list_objects

backend/app/database_ops/utils.py:86–212  ·  view source on GitHub ↗

Build sql script for listing operations :param conn: postgres connection :param object_class: the class of the object to build :param table_name: table name :param limit: the maximum number of records to return :param order: the order of records to return, desc or asc :p

(
    conn,
    object_class,
    table_name: str,
    order: SortOrderEnum,
    sort_field: str,
    object_id_name: Optional[str],
    limit: Optional[int] = None,
    after_id: Optional[str] = None,
    after_value: Optional[Any] = None,
    before_id: Optional[str] = None,
    before_value: Optional[Any] = None,
    offset: Optional[int] = None,
    prefix_filters: Optional[Dict] = None,
    equal_filters: Optional[Dict] = None,
)

Source from the content-addressed store, hash-verified

84
85
86async def list_objects(
87 conn,
88 object_class,
89 table_name: str,
90 order: SortOrderEnum,
91 sort_field: str,
92 object_id_name: Optional[str],
93 limit: Optional[int] = None,
94 after_id: Optional[str] = None,
95 after_value: Optional[Any] = None,
96 before_id: Optional[str] = None,
97 before_value: Optional[Any] = None,
98 offset: Optional[int] = None,
99 prefix_filters: Optional[Dict] = None,
100 equal_filters: Optional[Dict] = None,
101) -> ListResult:
102 """
103 Build sql script for listing operations
104 :param conn: postgres connection
105 :param object_class: the class of the object to build
106 :param table_name: table name
107 :param limit: the maximum number of records to return
108 :param order: the order of records to return, desc or asc
109 :param sort_field: the field to sort records by
110 :param object_id_name: the name of the object id
111 :param after_value: the cursor represented by a value to fetch the next page
112 :param after_id: the object id of the after cursor
113 :param before_value: the cursor represented by a value to fetch the previous page
114 :param before_id: the object id of the before cursor
115 :param offset: the offset of records to return
116 :param prefix_filters: the prefix filters, key is the column name, value is the prefix value
117 :param equal_filters: the equal filters, key is the column name, value is the equal value
118 :return: a tuple of list of objects, total_count and has_more
119
120 """
121
122 params = []
123 where_clauses = []
124
125 # assume all id fields are named as {table_name}_id
126 secondary_sort_field = object_id_name
127 after_secondary_value = after_id
128 before_secondary_value = before_id
129
130 # add prefix filters
131 if prefix_filters:
132 for field, value in prefix_filters.items():
133 if value is not None:
134 where_clauses.append(f"{field} LIKE ${len(params) + 1}")
135 params.append(f"{value}%")
136
137 # add equal filters
138 if equal_filters:
139 for field, value in equal_filters.items():
140 if value is not None:
141 where_clauses.append(f"{field} = ${len(params) + 1}")
142 params.append(value)
143

Callers

nothing calls this directly

Calls 2

get_object_totalFunction · 0.85
buildMethod · 0.45

Tested by

no test coverage detected