feat(task): record and display task completion time

Add DoneAt to the download task model: set when a task finishes and
cleared when it is downloaded again. The value flows through the API
model and task record, and is shown as "Completed at" in the task
drawer info tab next to the creation time.
This commit is contained in:
Levi committed 2026-09-20 08:56:54 +08:00
1 parent 694b43e3f9
commit 4b231f52c5
30 files changed
+82 -23

No files matched your search

+9
View File
@@ -32,6 +32,9 @@ type Task struct {
Progress *Progress `json:"progress"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
// DoneAt is the time when the task last completed; nil while the task has
// never finished or is being downloaded again.
DoneAt *time.Time `json:"doneAt"`
producer production.Source
producerReceived int64
@@ -134,6 +137,12 @@ func (t *Task) MarshalJSON() ([]byte, error) {
func (t *Task) updateStatus(status base.Status) {
t.UpdatedAt = time.Now()
t.Status = status
if status == base.DownloadStatusDone {
doneAt := time.Now()
t.DoneAt = &doneAt
} else {
t.DoneAt = nil
}
}
func (t *Task) clone() *Task {