Skip to content

Commit

Permalink
Small updates (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickp authored Oct 29, 2023
2 parents 2cb5bc7 + 9ad4679 commit 116773b
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 157 deletions.
289 changes: 158 additions & 131 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ arboard = "3.2"
async-trait = "0.1"
chrono = { version = "0.4", features = ["serde"] }
crossterm = "0.27"
csv = "1.2"
csv = "1.3"
fern = "0.6"
log = "0.4"
rand = "0.8"
Expand All @@ -34,7 +34,7 @@ sqlx = { version = "0.7", features = [ "runtime-tokio-native-tls" , "sqlite", "m
strum = "0.25"
strum_macros = "0.25"
thiserror = "1.0"
tokio = { version = "1.32", features = ["full"] }
ratatui = { version = "0.23.0", features = ["all-widgets"]}
uuid = { version = "1.4", features = ["v4", "fast-rng"] }
tokio = { version = "1.33", features = ["full"] }
ratatui = { version = "0.24.0", features = ["all-widgets"]}
uuid = { version = "1.5", features = ["v4", "fast-rng"] }
unicode-width = "0.1"
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel="nightly"
8 changes: 4 additions & 4 deletions src/app/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl Application {
pub fn current_parameter_description(&self) -> Option<String> {
self.state
.command_parameter_inputs
.get(0)
.first()
.map(|spec| spec.description())
}

Expand All @@ -145,14 +145,14 @@ impl Application {
.filter(|name| name.to_string().starts_with(self.state.input.current()))
.collect();
if names.len() == 1 {
let name = names.get(0).unwrap();
let name = names.first().unwrap();
self.state.input.set(name);
}
}

pub fn autocomplete_command_parameter(&mut self) {
if let Some(super::CommandParameterSpec::ArtistName { description: _ }) =
self.state.command_parameter_inputs.get(0)
self.state.command_parameter_inputs.first()
{
let matches: Vec<&ArtistName> = self
.processor
Expand All @@ -161,7 +161,7 @@ impl Application {
.filter(|artist_name| artist_name.starts_with(self.state.input.current()))
.collect();
if matches.len() == 1 {
self.state.input.set_text(&matches.get(0).unwrap().0);
self.state.input.set_text(&matches.first().unwrap().0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod state;

pub use application::Application;
pub use chart::BarChart;
pub use command_name::{CommandName, CommandNameIter};
pub use command_name::CommandName;
pub use command_parameters::{CommandParameterSpec, CommandParameters};
pub use has_id::HasId;
pub use input::Input;
Expand Down
2 changes: 1 addition & 1 deletion src/persistence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ mod writer;
pub use event_store::EventStore;
pub use format::Format;
pub use output_folder::OutputFolder;
pub use reader::Reader;

pub use state_store::StateStore;
pub use writer::Writer;
2 changes: 1 addition & 1 deletion src/persistence/sqlite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod state_store;
mod store;

pub use config::DatabaseConfig;
pub use listen_tracker_repository::{listen_tracker_repo, SqliteListenTrackerRepository};
pub use listen_tracker_repository::listen_tracker_repo;
pub use pool::build_pool_and_migrate;
pub use state_store::SqliteStateStore;
pub use store::SqliteEventStore;
4 changes: 2 additions & 2 deletions src/projections/statistics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ mod general;
mod time_played;

pub use artists_counts::ArtistsCounts;
pub use calendar_counts::{order_in_week, DayCounts, MonthCounts, YearCounts};
pub use calendar_counts::{order_in_week, MonthCounts};
pub use count::{ArtistAndSongCount, SongCount};
pub use counter::ArtistSongCounter;

pub use event_processor::EventProcessor;
pub use general::General;
pub use time_played::TimePlayed;
17 changes: 6 additions & 11 deletions src/render/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: Application) -
}
}

fn ui<B: Backend>(f: &mut Frame<B>, app: &Application) {
fn ui(f: &mut Frame, app: &Application) {
let chunks = Layout::default()
.direction(Direction::Vertical)
.margin(2)
Expand Down Expand Up @@ -255,8 +255,8 @@ fn ui<B: Backend>(f: &mut Frame<B>, app: &Application) {
}
}

fn render_message_set<B: Backend>(
f: &mut Frame<B>,
fn render_message_set(
f: &mut Frame,
chunk: Rect,
message_set: &MessageSet,
error_message: &Option<String>,
Expand Down Expand Up @@ -301,12 +301,7 @@ fn render_message_set<B: Backend>(
f.render_widget(blocks, chunk);
}

fn render_empty<B: Backend>(
f: &mut Frame<B>,
chunk: Rect,
error_message: &Option<String>,
mode: &Mode,
) {
fn render_empty(f: &mut Frame, chunk: Rect, error_message: &Option<String>, mode: &Mode) {
let mut messages: Vec<ListItem> = Vec::new();
if let Some(error_message) = error_message {
let content = vec![Line::from(Span::styled(
Expand All @@ -327,8 +322,8 @@ fn render_empty<B: Backend>(
f.render_widget(blocks, chunk);
}

fn render_chart<B: Backend>(
f: &mut Frame<B>,
fn render_chart(
f: &mut Frame,
chunk: Rect,
bar_chart_data: crate::app::BarChart,
current_page: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/track_plays/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod tests {
let plays = read_track_plays(&path).unwrap();
println!("{:?}", &plays);

let play = match plays.get(0).unwrap() {
let play = match plays.first().unwrap() {
TrackPlay::Spotify(it) => it,
TrackPlay::AppleMusicPlayActivity(_) => todo!(),
};
Expand Down

0 comments on commit 116773b

Please sign in to comment.