git list refactor

This commit is contained in:
2026-03-01 12:13:19 +03:00
parent 5d45b4adb0
commit f24200d52a
26 changed files with 10313 additions and 2179 deletions

View File

@@ -79,6 +79,67 @@ class ResourceService:
return result
# [/DEF:get_dashboards_with_status:Function]
# [DEF:get_dashboards_page_with_status:Function]
# @PURPOSE: Fetch one dashboard page from environment and enrich only that page with status metadata.
# @PRE: env is valid; page >= 1; page_size > 0.
# @POST: Returns page items plus total counters without scanning all pages locally.
# @PARAM: env (Environment) - Source environment.
# @PARAM: tasks (Optional[List[Task]]) - Tasks for latest LLM status.
# @PARAM: page (int) - 1-based page number.
# @PARAM: page_size (int) - Page size.
# @RETURN: Dict[str, Any] - {"dashboards": List[Dict], "total": int, "total_pages": int}
async def get_dashboards_page_with_status(
self,
env: Any,
tasks: Optional[List[Task]] = None,
page: int = 1,
page_size: int = 10,
search: Optional[str] = None,
include_git_status: bool = True,
) -> Dict[str, Any]:
with belief_scope(
"get_dashboards_page_with_status",
f"env={env.id}, page={page}, page_size={page_size}, search={search}",
):
client = SupersetClient(env)
total, dashboards_page = client.get_dashboards_summary_page(
page=page,
page_size=page_size,
search=search,
)
result = []
for dashboard in dashboards_page:
dashboard_dict = dashboard
dashboard_id = dashboard_dict.get("id")
if include_git_status:
dashboard_dict["git_status"] = self._get_git_status_for_dashboard(dashboard_id)
else:
dashboard_dict["git_status"] = None
dashboard_dict["last_task"] = self._get_last_llm_task_for_dashboard(
dashboard_id,
env.id,
tasks,
)
result.append(dashboard_dict)
total_pages = (total + page_size - 1) // page_size if total > 0 else 1
logger.info(
"[ResourceService][Coherence:OK] Fetched dashboards page %s/%s (%s items, total=%s)",
page,
total_pages,
len(result),
total,
)
return {
"dashboards": result,
"total": total,
"total_pages": total_pages,
}
# [/DEF:get_dashboards_page_with_status:Function]
# [DEF:_get_last_llm_task_for_dashboard:Function]
# @PURPOSE: Get most recent LLM validation task for a dashboard in an environment
# @PRE: dashboard_id is a valid integer identifier