MCPcopy
hub / github.com/ModelEngine-Group/nexent / get_all_tenant_ids

Function get_all_tenant_ids

backend/database/tenant_config_db.py:143–163  ·  view source on GitHub ↗

Get all tenant IDs that have tenant configurations, sorted by creation time descending (newest first). Returns: List[str]: List of tenant IDs sorted by creation time (newest first)

()

Source from the content-addressed store, hash-verified

141
142
143def get_all_tenant_ids():
144 """
145 Get all tenant IDs that have tenant configurations, sorted by creation time descending (newest first).
146
147 Returns:
148 List[str]: List of tenant IDs sorted by creation time (newest first)
149 """
150 with get_db_session() as session:
151 # Query tenant_ids grouped by tenant_id, ordered by maximum create_time (newest config creation)
152 result = session.query(
153 TenantConfig.tenant_id,
154 func.max(TenantConfig.create_time).label("max_create_time")
155 ).filter(
156 TenantConfig.delete_flag == "N"
157 ).group_by(
158 TenantConfig.tenant_id
159 ).order_by(
160 func.max(TenantConfig.create_time).desc()
161 ).all()
162
163 return [row[0] for row in result]

Callers 4

check_tenant_name_existsFunction · 0.90
get_tenants_paginatedFunction · 0.90

Calls 6

get_db_sessionFunction · 0.90
allMethod · 0.45
order_byMethod · 0.45
filterMethod · 0.45
queryMethod · 0.45
descMethod · 0.45

Tested by 2