mirror of
https://github.com/clearml/clearml-server
synced 2025-04-07 22:44:13 +00:00
Support sorting by task active duration
This commit is contained in:
parent
0ef018c931
commit
b89de43373
@ -327,11 +327,14 @@ class TaskBLL(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_last_update(
|
def set_last_update(
|
||||||
task_ids: Collection[str], company_id: str, last_update: datetime
|
task_ids: Collection[str], company_id: str, last_update: datetime, **extra_updates
|
||||||
):
|
):
|
||||||
return Task.objects(id__in=task_ids, company=company_id).update(
|
tasks = Task.objects(id__in=task_ids, company=company_id).only("status", "started")
|
||||||
upsert=False, last_update=last_update
|
for task in tasks:
|
||||||
)
|
updates = extra_updates
|
||||||
|
if task.status == TaskStatus.in_progress and task.started:
|
||||||
|
updates = {"active_duration": (datetime.utcnow() - task.started).total_seconds(), **extra_updates}
|
||||||
|
Task.objects(id=task.id, company=company_id).update(upsert=False, last_update=last_update, **updates)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_statistics(
|
def update_statistics(
|
||||||
@ -394,8 +397,8 @@ class TaskBLL(object):
|
|||||||
}
|
}
|
||||||
extra_updates["metric_stats"] = metric_stats
|
extra_updates["metric_stats"] = metric_stats
|
||||||
|
|
||||||
Task.objects(id=task_id, company=company_id).update(
|
TaskBLL.set_last_update(
|
||||||
upsert=False, last_update=last_update, **extra_updates
|
task_ids=[task_id], company_id=company_id, last_update=last_update, **extra_updates
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -150,6 +150,7 @@ class Task(AttributedDocument):
|
|||||||
"created",
|
"created",
|
||||||
"started",
|
"started",
|
||||||
"completed",
|
"completed",
|
||||||
|
"active_duration",
|
||||||
"parent",
|
"parent",
|
||||||
"project",
|
"project",
|
||||||
("company", "name"),
|
("company", "name"),
|
||||||
@ -203,6 +204,7 @@ class Task(AttributedDocument):
|
|||||||
started = DateTimeField()
|
started = DateTimeField()
|
||||||
completed = DateTimeField()
|
completed = DateTimeField()
|
||||||
published = DateTimeField()
|
published = DateTimeField()
|
||||||
|
active_duration = IntField(default=0)
|
||||||
parent = StringField()
|
parent = StringField()
|
||||||
project = StringField(reference_field=Project, user_set_allowed=True)
|
project = StringField(reference_field=Project, user_set_allowed=True)
|
||||||
output: Output = EmbeddedDocumentField(Output, default=Output)
|
output: Output = EmbeddedDocumentField(Output, default=Output)
|
||||||
|
@ -434,6 +434,10 @@ _definitions {
|
|||||||
type: string
|
type: string
|
||||||
format: "date-time"
|
format: "date-time"
|
||||||
}
|
}
|
||||||
|
active_duration {
|
||||||
|
description: "Task duration time (seconds)"
|
||||||
|
type: integer
|
||||||
|
}
|
||||||
parent {
|
parent {
|
||||||
description: "Parent task id"
|
description: "Parent task id"
|
||||||
type: string
|
type: string
|
||||||
|
Loading…
Reference in New Issue
Block a user