Skip to content

Commit 72ef9dc

Browse files
committed
Add Ok filter in progress page
1 parent d839fc5 commit 72ef9dc

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/extractors/torrent_list.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ pub enum TorrentListFilter {
6969
Ongoing,
7070
Stuck,
7171
Unmanaged,
72+
Ok,
7273
}
7374

7475
impl TorrentListFilter {
7576
pub fn filter_torrent_list(&self, list: TorrentList) -> Vec<Torrent> {
7677
let mut list: Vec<Torrent> = match self {
7778
Self::Everything => list.into_iter().collect(),
7879
Self::Ongoing => list.into_iter().filter(is_torrent_ongoing).collect(),
80+
Self::Ok => list.into_iter().filter(is_torrent_ok).collect(),
7981
Self::Stuck => list.into_iter().filter(is_torrent_stuck).collect(),
8082
Self::Unmanaged => list.into_iter().filter(is_torrent_unmanaged).collect(),
8183
};
@@ -98,6 +100,8 @@ pub struct TorrentListCounter {
98100
/// Torrents not known to TorrentManager.
99101
// TODO: this is actually not implemented yet
100102
pub unmanaged: u32,
103+
/// Torrent successfully downloaded
104+
pub ok: u32,
101105
}
102106

103107
impl TorrentListCounter {
@@ -122,6 +126,11 @@ impl TorrentListCounter {
122126
continue;
123127
}
124128

129+
if is_torrent_ok(torrent) {
130+
counter.ok += 1;
131+
continue;
132+
}
133+
125134
// Otherwise, the torrent is simply seeding,
126135
// and we simply don't care.
127136
}
@@ -136,6 +145,12 @@ pub fn is_torrent_unmanaged(_t: &Torrent) -> bool {
136145
false
137146
}
138147

148+
/// Check if torrent hasn't finished (progress < 100%)
149+
/// and is less than 24h hours.
150+
pub fn is_torrent_ok(t: &Torrent) -> bool {
151+
t.progress == 100
152+
}
153+
139154
/// Check if torrent hasn't finished (progress < 100%)
140155
/// and is less than 24h hours.
141156
pub fn is_torrent_ongoing(t: &Torrent) -> bool {

templates/menus/progress.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<div class="filters d-flex align-items-center gap-3 flex-wrap">
22
<a class="filter-item {% if filter.is_filter(TorrentListFilter::Everything) %}filter-item--active{% endif %}" href="/progress/everything">
3-
<span>Everything ({{ torrent_list.counter.everything }})</span>
3+
<span>All ({{ torrent_list.counter.everything }})</span>
4+
</a>
5+
6+
<a class="filter-item {% if filter.is_filter(TorrentListFilter::Ok) %}filter-item--active{% endif %}" href="/progress/ok">
7+
<span>Ok ({{ torrent_list.counter.ok }})</span>
48
</a>
59

610
<a class="filter-item {% if filter.is_filter(TorrentListFilter::Ongoing) %}filter-item--active{% endif %}" href="/progress/ongoing">

0 commit comments

Comments
 (0)