mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-01 23:20:47 +08:00
feat: add seed ratio display
This commit is contained in:
@@ -15,7 +15,8 @@ import (
|
||||
|
||||
type Activity struct {
|
||||
*ent.History
|
||||
Progress int `json:"progress"`
|
||||
Progress int `json:"progress"`
|
||||
SeedRatio float32 `json:"seed_ratio"`
|
||||
}
|
||||
|
||||
func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
|
||||
@@ -35,6 +36,7 @@ func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
|
||||
for id, task := range s.core.GetTasks() {
|
||||
if h.ID == id && task.Exists() {
|
||||
a.Progress = task.Progress()
|
||||
a.SeedRatio = float32(*task.SeedRatio())
|
||||
}
|
||||
}
|
||||
activities = append(activities, a)
|
||||
|
||||
@@ -49,7 +49,7 @@ func (c *Client) checkTasks() {
|
||||
torrent := c.tasks[id]
|
||||
ok := c.isSeedRatioLimitReached(r.IndexerID, torrent)
|
||||
if ok {
|
||||
log.Infof("torrent file seed ratio reached, remove: %v", torrent.Name())
|
||||
log.Infof("torrent file seed ratio reached, remove: %v, current seed ratio: %v", torrent.Name(), torrent.SeedRatio())
|
||||
torrent.Remove()
|
||||
delete(c.tasks, id)
|
||||
} else {
|
||||
@@ -138,7 +138,7 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
|
||||
//判断是否需要删除本地文件
|
||||
ok := c.isSeedRatioLimitReached(r.IndexerID, torrent)
|
||||
if downloadclient.RemoveCompletedDownloads && ok {
|
||||
log.Debugf("download complete,remove torrent and files related")
|
||||
log.Debugf("download complete,remove torrent and files related, torrent: %v, seed ratio: %v", torrentName, torrent.SeedRatio())
|
||||
delete(c.tasks, r.ID)
|
||||
torrent.Remove()
|
||||
}
|
||||
|
||||
@@ -54,12 +54,15 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
||||
],
|
||||
),
|
||||
Builder(builder: (context) {
|
||||
var activitiesWatcher = ref.watch(activitiesDataProvider("active"));
|
||||
AsyncValue<List<Activity>>? activitiesWatcher;
|
||||
|
||||
if (selectedTab == 1) {
|
||||
activitiesWatcher = ref.watch(activitiesDataProvider("archive"));
|
||||
} else if (selectedTab == 0) {
|
||||
activitiesWatcher = ref.watch(activitiesDataProvider("active"));
|
||||
}
|
||||
|
||||
return activitiesWatcher.when(
|
||||
return activitiesWatcher!.when(
|
||||
data: (activities) {
|
||||
return Flexible(
|
||||
child: ListView.builder(
|
||||
@@ -107,15 +110,15 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
||||
),
|
||||
);
|
||||
}(),
|
||||
title:
|
||||
Text( (ac.sourceTitle ?? "")),
|
||||
title: Text((ac.sourceTitle ?? "")),
|
||||
subtitle: Opacity(
|
||||
opacity: 0.7,
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text("开始时间:${timeago.format(ac.date!)}"),
|
||||
Text("大小:${(ac.size ?? 0).readableFileSize()}")
|
||||
Text("大小:${(ac.size ?? 0).readableFileSize()}"),
|
||||
ac.seedRatio > 0 ?Text("分享率:${ac.seedRatio}"): SizedBox()
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -69,7 +69,8 @@ class Activity {
|
||||
required this.status,
|
||||
required this.saved,
|
||||
required this.progress,
|
||||
required this.size});
|
||||
required this.size,
|
||||
required this.seedRatio});
|
||||
|
||||
final int? id;
|
||||
final int? mediaId;
|
||||
@@ -81,6 +82,7 @@ class Activity {
|
||||
final String? saved;
|
||||
final int? progress;
|
||||
final int? size;
|
||||
final double seedRatio;
|
||||
|
||||
factory Activity.fromJson(Map<String, dynamic> json) {
|
||||
return Activity(
|
||||
@@ -93,6 +95,7 @@ class Activity {
|
||||
status: json["status"],
|
||||
saved: json["saved"],
|
||||
progress: json["progress"],
|
||||
seedRatio: json["seed_ratio"],
|
||||
size: json["size"]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user