Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Feb 11, 2024
1 parent 790eed3 commit 98adfc4
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 25 deletions.
1 change: 1 addition & 0 deletions crates/hyperqueue/src/dashboard/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub use fetch::create_data_fetch_process;
pub use time_based_vec::ItemWithTime;
pub use time_interval::TimeRange;

#[allow(clippy::module_inception)]
mod data;
mod fetch;
mod time_based_vec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub enum WorkerStatus {
}

pub struct WorkerRecord {
id: WorkerId,
connection_time: SystemTime,
worker_config: WorkerConfiguration,
worker_overviews: TimeBasedVec<WorkerOverview>,
Expand Down Expand Up @@ -53,7 +52,6 @@ impl WorkerTimeline {
self.workers.insert(
*id,
WorkerRecord {
id: *id,
connection_time: event.time,
worker_config: *info.clone(),
worker_overviews: Default::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ impl AllocationInfoTable {
self.table.select_previous_wrap();
}

pub fn get_selected_allocation_id(&self) -> Option<&AllocationId> {
let selection = self.table.current_selection();
selection.map(|(id, _)| id)
}

pub fn clear_selection(&mut self) {
self.table.clear_selection();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl WorkerCountChart {
let worker_counts: Vec<(f64, f64)> = self
.worker_records
.iter()
.map(|record| (get_time_as_secs(record.time) as f64, record.count as f64))
.map(|record| (get_time_as_secs(record.time), record.count as f64))
.collect();
let datasets = vec![Dataset::default()
.name("Connected workers")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ impl WorkerTable {
let mut rows: Vec<WorkerRow> = data
.workers()
.get_known_worker_ids_at(current_time)
.into_iter()
.map(|(worker_id, status)| {
let config = data.workers().get_worker_config_for(worker_id);
let hostname = config.map(|config| config.hostname.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn render_cpu_util_table(
human_size(mem_used),
human_size(mem_util.total)
));
let body_block = styles::table_block_with_title(title.into());
let body_block = styles::table_block_with_title(title);

let table = Table::new(rows, constraints)
.block(body_block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl WorkerOverviewFragment {
)
})
{
self.worker_per_core_cpu_util = cpu_util.into_iter().map(|&v| v as f64).collect();
self.worker_per_core_cpu_util = cpu_util.iter().map(|&v| v as f64).collect();
self.worker_mem_util = mem_util.clone();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ impl WorkerUtilizationChart {
.iter()
.map(|record| {
(
get_time_as_secs(record.time) as f64,
record
.item
.hw_state
.as_ref()
.map(|state| get_value(&state))
.unwrap_or(0.0),
get_time_as_secs(record.time),
record.item.hw_state.as_ref().map(&get_value).unwrap_or(0.0),
)
})
.collect::<Vec<(f64, f64)>>()
Expand Down Expand Up @@ -112,11 +107,11 @@ impl WorkerUtilizationChart {

pub fn update(&mut self, data: &DashboardData, worker_id: WorkerId) {
let time_range = data.current_time_range();
let overviews = data
self.overviews = data
.workers()
.get_worker_overviews_at(worker_id, time_range)
.unwrap_or(&[]);
self.overviews = overviews.into_iter().cloned().collect();
.unwrap_or(&[])
.to_vec();
self.range = time_range;
}
}
2 changes: 1 addition & 1 deletion crates/hyperqueue/src/dashboard/ui/screens/root_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn get_root_screen_chunks(frame: &DashboardFrame) -> RootChunks {

/// Renders the top `tab bar` of the dashboard.
pub fn render_screen_tabs(current_screen: SelectedScreen, rect: Rect, frame: &mut DashboardFrame) {
let screen_names = vec!["Jobs", "AutoAllocator", "Workers"];
let screen_names = ["Jobs", "AutoAllocator", "Workers"];
let screen_titles: Vec<Line> = screen_names
.iter()
.map(|t| {
Expand Down
4 changes: 2 additions & 2 deletions crates/hyperqueue/src/dashboard/ui/widgets/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ impl DashboardChart {
.title("t->")
.style(Style::default().fg(Color::Gray))
.bounds([
get_time_as_secs(self.end_time - self.view_size) as f64,
get_time_as_secs(self.end_time) as f64,
get_time_as_secs(self.end_time - self.view_size),
get_time_as_secs(self.end_time),
])
.labels(vec![
Span::from(start_time_label.format("%H:%M").to_string()),
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperqueue/src/dashboard/ui_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn send_event_repeatedly(
fn setup_panics() {
let default_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
write!(io::stdout(), "{}", ToMainScreen).unwrap();
print!("{}", ToMainScreen);
io::stdout()
.into_raw_mode()
.unwrap()
Expand Down

0 comments on commit 98adfc4

Please sign in to comment.