mirror of
https://github.com/clearml/clearml-server
synced 2025-03-12 06:51:37 +00:00
Fix projects own_tasks does not take task state filter into account
This commit is contained in:
parent
d9579891c8
commit
741fa84b52
@ -1146,6 +1146,7 @@ class ProjectBLL:
|
||||
company: str,
|
||||
project_ids: Sequence[str],
|
||||
filter_: Mapping[str, Any] = None,
|
||||
specific_state: Optional[EntityVisibility] = None,
|
||||
users: Sequence[str] = None,
|
||||
) -> Dict[str, dict]:
|
||||
"""
|
||||
@ -1156,6 +1157,20 @@ class ProjectBLL:
|
||||
if not project_ids:
|
||||
return {}
|
||||
|
||||
if specific_state:
|
||||
filter_ = filter_ or {}
|
||||
system_tags_filter = filter_.get("system_tags", [])
|
||||
archived = EntityVisibility.archived.value
|
||||
non_archived = f"-{EntityVisibility.archived.value}"
|
||||
if not any(t in system_tags_filter for t in (archived, non_archived)):
|
||||
filter_ = {k: v for k, v in filter_.items()}
|
||||
filter_["system_tags"] = [
|
||||
archived
|
||||
if specific_state == EntityVisibility.archived
|
||||
else non_archived,
|
||||
*system_tags_filter,
|
||||
]
|
||||
|
||||
pipeline = [
|
||||
{
|
||||
"$match": cls.get_match_conditions(
|
||||
|
@ -201,6 +201,7 @@ def get_all_ex(call: APICall, company_id: str, request: ProjectsGetRequest):
|
||||
company=company_id,
|
||||
project_ids=project_ids,
|
||||
filter_=stats_filter,
|
||||
specific_state=request.stats_for_state,
|
||||
users=request.active_users,
|
||||
)
|
||||
|
||||
|
@ -348,7 +348,7 @@ class TestSubProjects(TestService):
|
||||
id=[project1, project2], check_own_contents=True
|
||||
).projects
|
||||
res1 = next(p for p in res if p.id == project1)
|
||||
self.assertEqual(res1.own_tasks, 2)
|
||||
self.assertEqual(res1.own_tasks, 1)
|
||||
self.assertEqual(res1.own_models, 1)
|
||||
|
||||
res2 = next(p for p in res if p.id == project2)
|
||||
|
Loading…
Reference in New Issue
Block a user