mirror of
https://github.com/clearml/clearml-server
synced 2025-01-31 02:46:53 +00:00
Fix tasks/models.edit_tags do not update the task/model last_changed time
This commit is contained in:
parent
2eee909364
commit
9dfb4b882a
@ -1,4 +1,5 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Sequence, Dict, Type
|
from typing import Sequence, Dict, Type
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ class OrgBLL:
|
|||||||
def edit_entity_tags(
|
def edit_entity_tags(
|
||||||
self,
|
self,
|
||||||
company_id,
|
company_id,
|
||||||
|
user_id: str,
|
||||||
entity_cls: Type[AttributedDocument],
|
entity_cls: Type[AttributedDocument],
|
||||||
entity_ids: Sequence[str],
|
entity_ids: Sequence[str],
|
||||||
add_tags: Sequence[str],
|
add_tags: Sequence[str],
|
||||||
@ -47,13 +49,17 @@ class OrgBLL:
|
|||||||
)
|
)
|
||||||
|
|
||||||
updated = 0
|
updated = 0
|
||||||
|
last_changed = {
|
||||||
|
"set__last_change": datetime.utcnow(),
|
||||||
|
"set__last_changed_by": user_id,
|
||||||
|
}
|
||||||
if add_tags:
|
if add_tags:
|
||||||
updated += entity_cls.objects(company=company_id, id__in=entity_ids).update(
|
updated += entity_cls.objects(company=company_id, id__in=entity_ids).update(
|
||||||
add_to_set__tags=add_tags
|
add_to_set__tags=add_tags, **last_changed,
|
||||||
)
|
)
|
||||||
if remove_tags:
|
if remove_tags:
|
||||||
updated += entity_cls.objects(company=company_id, id__in=entity_ids).update(
|
updated += entity_cls.objects(company=company_id, id__in=entity_ids).update(
|
||||||
pull_all__tags=remove_tags
|
pull_all__tags=remove_tags, **last_changed,
|
||||||
)
|
)
|
||||||
if not updated:
|
if not updated:
|
||||||
return 0
|
return 0
|
||||||
|
@ -761,10 +761,11 @@ def move(call: APICall, company_id: str, request: MoveRequest):
|
|||||||
|
|
||||||
|
|
||||||
@endpoint("models.update_tags")
|
@endpoint("models.update_tags")
|
||||||
def update_tags(_, company_id: str, request: UpdateTagsRequest):
|
def update_tags(call: APICall, company_id: str, request: UpdateTagsRequest):
|
||||||
return {
|
return {
|
||||||
"updated": org_bll.edit_entity_tags(
|
"updated": org_bll.edit_entity_tags(
|
||||||
company_id=company_id,
|
company_id=company_id,
|
||||||
|
user_id=call.identity.user,
|
||||||
entity_cls=Model,
|
entity_cls=Model,
|
||||||
entity_ids=request.ids,
|
entity_ids=request.ids,
|
||||||
add_tags=request.add_tags,
|
add_tags=request.add_tags,
|
||||||
|
@ -1504,6 +1504,7 @@ def update_tags(call: APICall, company_id: str, request: UpdateTagsRequest):
|
|||||||
return {
|
return {
|
||||||
"updated": org_bll.edit_entity_tags(
|
"updated": org_bll.edit_entity_tags(
|
||||||
company_id=company_id,
|
company_id=company_id,
|
||||||
|
user_id=call.identity.user,
|
||||||
entity_cls=Task,
|
entity_cls=Task,
|
||||||
entity_ids=request.ids,
|
entity_ids=request.ids,
|
||||||
add_tags=request.add_tags,
|
add_tags=request.add_tags,
|
||||||
|
Loading…
Reference in New Issue
Block a user