Fix tasks/models.edit_tags do not update the task/model last_changed time

This commit is contained in:
clearml 2024-12-05 22:22:49 +02:00
parent 2eee909364
commit 9dfb4b882a
3 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,5 @@
from collections import defaultdict
from datetime import datetime
from enum import Enum
from typing import Sequence, Dict, Type
@ -28,6 +29,7 @@ class OrgBLL:
def edit_entity_tags(
self,
company_id,
user_id: str,
entity_cls: Type[AttributedDocument],
entity_ids: Sequence[str],
add_tags: Sequence[str],
@ -47,13 +49,17 @@ class OrgBLL:
)
updated = 0
last_changed = {
"set__last_change": datetime.utcnow(),
"set__last_changed_by": user_id,
}
if add_tags:
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:
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:
return 0

View File

@ -761,10 +761,11 @@ def move(call: APICall, company_id: str, request: MoveRequest):
@endpoint("models.update_tags")
def update_tags(_, company_id: str, request: UpdateTagsRequest):
def update_tags(call: APICall, company_id: str, request: UpdateTagsRequest):
return {
"updated": org_bll.edit_entity_tags(
company_id=company_id,
user_id=call.identity.user,
entity_cls=Model,
entity_ids=request.ids,
add_tags=request.add_tags,

View File

@ -1504,6 +1504,7 @@ def update_tags(call: APICall, company_id: str, request: UpdateTagsRequest):
return {
"updated": org_bll.edit_entity_tags(
company_id=company_id,
user_id=call.identity.user,
entity_cls=Task,
entity_ids=request.ids,
add_tags=request.add_tags,