feat: show sizes under a gigabyte in megabytes
Every size cell converted bytes to gigabytes and formatted the float in place, so anything below a gigabyte rendered as 0.00 GB. Books and tracks are almost always that small, which made the Size columns in Readarr and Lidarr useless. Replace convert_to_gb and convert_f64_to_gb with one format_size helper that renders gigabytes at or above 1 GiB and megabytes below it, at the precision each site already used. Every render site across the four servarr trees now calls it, including the two movie and episode detail strings built on the network side. Values at or above a gigabyte render byte for byte as before. Give the Readarr book statistics and book file fixtures and the Lidarr album statistics fixture realistic sub-gigabyte sizes so the megabyte path is pinned by the committed snapshots.
This commit is contained in:
117 files changed
+241
-250
No files matched your search
@@ -12,7 +12,7 @@ use crate::ui::utils::{get_width_from_percentage, layout_block_top_border};
|
||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::utils::convert_to_gb;
|
||||
use crate::utils::format_size;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "downloads_ui_tests.rs"]
|
||||
@@ -96,12 +96,12 @@ fn draw_downloads(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
} else {
|
||||
1f64 - (*sizeleft as f64 / *size as f64)
|
||||
};
|
||||
let file_size: f64 = convert_to_gb(*size);
|
||||
let file_size = format_size(*size, 2);
|
||||
|
||||
Row::new(vec![
|
||||
Cell::from(title.to_owned()),
|
||||
Cell::from(format!("{:.0}%", percent * 100.0)),
|
||||
Cell::from(format!("{file_size:.2} GB")),
|
||||
Cell::from(file_size),
|
||||
Cell::from(
|
||||
output_path
|
||||
.as_ref()
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::ui::utils::{get_width_from_percentage, layout_block_top_border};
|
||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::utils::{convert_runtime, convert_to_gb};
|
||||
use crate::utils::{convert_runtime, format_size};
|
||||
|
||||
mod add_movie_ui;
|
||||
mod delete_movie_ui;
|
||||
@@ -95,7 +95,7 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let monitored = if movie.monitored { "🏷" } else { "" };
|
||||
let studio = movie.studio.clone().unwrap_or_default();
|
||||
let (hours, minutes) = convert_runtime(movie.runtime);
|
||||
let file_size: f64 = convert_to_gb(movie.size_on_disk);
|
||||
let file_size = format_size(movie.size_on_disk, 2);
|
||||
let certification = movie.certification.clone().unwrap_or_default();
|
||||
let quality_profile = quality_profile_map
|
||||
.get_by_left(&movie.quality_profile_id)
|
||||
@@ -121,7 +121,7 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
Cell::from(format!("{hours}h {minutes}m")),
|
||||
Cell::from(certification),
|
||||
Cell::from(movie.original_language.name.to_owned()),
|
||||
Cell::from(format!("{file_size:.2} GB")),
|
||||
Cell::from(file_size),
|
||||
Cell::from(quality_profile),
|
||||
Cell::from(monitored.to_owned()),
|
||||
Cell::from(tags),
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{DrawUi, draw_popup, draw_tabs};
|
||||
use crate::utils::convert_to_gb;
|
||||
use crate::utils::format_size;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "movie_details_ui_tests.rs"]
|
||||
@@ -398,7 +398,7 @@ fn draw_movie_releases(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
&& current_route != ActiveRadarrBlock::ManualSearchConfirmPrompt.into(),
|
||||
app.should_text_scroll,
|
||||
);
|
||||
let size = convert_to_gb(*size);
|
||||
let size = format_size(*size, 1);
|
||||
let rejected_str = if *rejected { "⛔" } else { "" };
|
||||
let peers = if seeders.is_none() || leechers.is_none() {
|
||||
Text::from("")
|
||||
@@ -434,7 +434,7 @@ fn draw_movie_releases(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
Cell::from(rejected_str),
|
||||
Cell::from(title.to_string()),
|
||||
Cell::from(indexer.clone()),
|
||||
Cell::from(format!("{size:.1} GB")),
|
||||
Cell::from(size),
|
||||
Cell::from(peers),
|
||||
Cell::from(language),
|
||||
Cell::from(quality),
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ expression: output
|
||||
│ Details │ History │ File │ Cast │ Crew │ Manual Search │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source ▼ Age ⛔ Title Indexer Size Peers Language Quality │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 GB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 GB English HD - 1080p │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 MB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 MB English HD - 1080p │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ expression: output
|
||||
│ Details │ History │ File │ Cast │ Crew │ Manual Search │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source ▼ Age ⛔ Title Indexer Size Peers Language Quality │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 GB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 GB English HD - 1080p │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 MB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 MB English HD - 1080p │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ expression: output
|
||||
│ Details │ History │ File │ Cast │ Crew │ Manual Search │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source Age ⛔ Title Indexer Size Peers Language Quality │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 GB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 GB English HD - 1080p │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 MB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 MB English HD - 1080p │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ expression: output
|
||||
│ Details │ History │ File │ Cast │ Crew │ Manual Search │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source ▼ Age ⛔ Title Indexer Size Peers Language Quality │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 GB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 GB English HD - 1080p │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 MB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 MB English HD - 1080p │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ expression: output
|
||||
│ Details │ History │ File │ Cast │ Crew │ Manual Search │
|
||||
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
|
||||
│ Source ▼ Age ⛔ Title Indexer Size Peers Language Quality │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 GB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 GB English HD - 1080p │
|
||||
│=> torrent 12 days ⛔ Some movie release The Pirate Bay 0.0 MB 25 / 3 English HD - 1080p │
|
||||
│ usenet 22 days ⛔ Some Other movie rele The Pirate Bay 0.0 MB English HD - 1080p │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::ui::utils::{
|
||||
line_gauge_with_label, line_gauge_with_title, title_block,
|
||||
};
|
||||
use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::utils::convert_to_gb;
|
||||
use crate::utils::format_size;
|
||||
use chrono::Duration;
|
||||
#[cfg(not(test))]
|
||||
use chrono::Utc;
|
||||
@@ -170,8 +170,8 @@ fn draw_stats_context(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
let RootFolder {
|
||||
path, free_space, ..
|
||||
} = &monitored_root_folders[i];
|
||||
let space: f64 = convert_to_gb(*free_space);
|
||||
let root_folder_space = Paragraph::new(format!("{path}: {space:.2} GB free"))
|
||||
let space = format_size(*free_space, 2);
|
||||
let root_folder_space = Paragraph::new(format!("{path}: {space} free"))
|
||||
.block(borderless_block())
|
||||
.default_color();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{DrawUi, draw_input_box_popup, draw_popup};
|
||||
use crate::utils::convert_to_gb;
|
||||
use crate::utils::format_size;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "root_folders_ui_tests.rs"]
|
||||
@@ -66,11 +66,11 @@ fn draw_root_folders(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
..
|
||||
} = root_folders;
|
||||
|
||||
let space: f64 = convert_to_gb(*free_space);
|
||||
let space = format_size(*free_space, 2);
|
||||
|
||||
Row::new(vec![
|
||||
Cell::from(path.to_owned()),
|
||||
Cell::from(format!("{space:.2} GB")),
|
||||
Cell::from(space),
|
||||
Cell::from(
|
||||
unmapped_folders
|
||||
.as_ref()
|
||||
|
||||
Reference in new issue
Block a user