feat: add upload progress and fix panic

This commit is contained in:
Simon Ding
2024-11-17 21:57:14 +08:00
parent 7d5ce8ba97
commit ba3f6de852
5 changed files with 23 additions and 5 deletions

View File

@@ -17,8 +17,9 @@ import (
type Activity struct {
*ent.History
Progress int `json:"progress"`
SeedRatio float64 `json:"seed_ratio"`
Progress int `json:"progress"`
SeedRatio float64 `json:"seed_ratio"`
UploadProgress float64 `json:"upload_progress"`
}
func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
@@ -44,6 +45,9 @@ func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
} else {
a.SeedRatio = r
}
if task.UploadProgresser != nil {
a.UploadProgress = task.UploadProgresser()
}
}
}
activities = append(activities, a)