From 69d847a1fc8caa18d84858f7c9d84b155e305e49 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Wed, 3 Jun 2026 22:27:40 -0600 Subject: [PATCH] Update to trane v0.29.0 --- Cargo.lock | 8 +++++--- Cargo.toml | 4 ++-- src/app.rs | 28 +++++++++++++++++++++++++--- src/cli.rs | 7 +++++++ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57d36cd..a0b7d32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1801,12 +1801,13 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "trane" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04d70ed1d2e4be11ddc05de4970fbb3ba2b8ef3101460b0f1352de40733bcac8" +checksum = "92bb377a63419f9bce7b378d521a4bee88d97a7437a2ed996a78ca211a0f089e" dependencies = [ "anyhow", "chrono", + "clap", "derive_builder", "indoc", "parking_lot", @@ -1818,6 +1819,7 @@ dependencies = [ "serde", "serde_json", "strum", + "tempfile", "thiserror", "ustr", "walkdir", @@ -1825,7 +1827,7 @@ dependencies = [ [[package]] name = "trane-cli" -version = "0.28.0" +version = "0.29.0" dependencies = [ "anyhow", "built", diff --git a/Cargo.toml b/Cargo.toml index c2d5f07..d0c2171 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "trane-cli" -version = "0.28.0" +version = "0.29.0" build = "build.rs" default-run = "trane" @@ -29,7 +29,7 @@ rustyline-derive = "0.11.1" tempfile = "3.27.0" serde_json = "1.0.149" termimad = "0.34.1" -trane = "0.28.0" +trane = "0.29.0" # Commented out for use in local development. # trane = { path = "../trane" } ustr = { version = "1.1.0", features = ["serde"] } diff --git a/src/app.rs b/src/app.rs index c105f01..a8e1e83 100644 --- a/src/app.rs +++ b/src/app.rs @@ -16,6 +16,7 @@ use trane::{ exercise_scorer::{ExerciseScorer, PowerLawScorer}, filter_manager::FilterManager, graph::UnitGraph, + practice_deltas::PracticeDeltas, practice_rewards::PracticeRewards, practice_stats::PracticeStats, preferences_manager::PreferencesManager, @@ -269,6 +270,17 @@ impl TraneApp { } } + /// Prints the current batch of exercises to the terminal. + pub fn show_batch(&self) -> Result<()> { + ensure!(self.trane.is_some(), "no Trane instance is open"); + + println!("Batch size: {}", self.batch.len()); + for exercise in &self.batch { + println!("Exercise ID: {}", exercise.id); + } + Ok(()) + } + /// Exports the dependent graph as a DOT file to the given path. pub fn export_graph(&self, path: &Path, courses_only: bool) -> Result<()> { ensure!(self.trane.is_some(), "no Trane instance is open"); @@ -935,9 +947,19 @@ impl TraneApp { // Compute the score, reward, and decide if it needs to be applied. let scorer = PowerLawScorer {}; let reward_scorer = WeightedRewardScorer {}; - let score = scorer.score(exercise_type, &previous_trials)?; + let deltas = self + .trane + .as_ref() + .unwrap() + .get_deltas(exercise_id, num_scores)?; + let score = scorer.score( + exercise_type, + &previous_trials, + &deltas, + Utc::now().timestamp(), + )?; let mut reward = reward_scorer.score_rewards(&course_rewards, &lesson_rewards)?; - let mut total_score = score; + let mut total_score = score.value; let apply_reward = reward_scorer.apply_reward(reward, &previous_trials); if apply_reward { total_score += reward; @@ -950,7 +972,7 @@ impl TraneApp { println!(); println!("Note: Rewards are only applied to exercises with previous scores"); println!(); - println!("Score: {score:.2}"); + println!("Score: {:.2}", score.value); println!("Reward: {reward:.2}"); println!("Final score: {total_score:.2}"); println!(); diff --git a/src/cli.rs b/src/cli.rs index 0e94918..609fa8d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -73,6 +73,9 @@ pub(crate) enum BlacklistSubcommands { /// Contains subcommands used for debugging. #[derive(Clone, Debug, Subcommand)] pub(crate) enum DebugSubcommands { + #[clap(about = "Prints the IDs of all the exercises in the current batch")] + Batch, + #[clap(about = "Exports the dependent graph as a DOT file to the given path")] ExportGraph { #[clap(help = "The path to the DOT file")] @@ -549,6 +552,10 @@ impl TraneCli { } Subcommands::Debug(subcommand) => match subcommand { + DebugSubcommands::Batch => { + app.show_batch()?; + Ok(true) + } DebugSubcommands::ExportGraph { path, courses_only } => { app.export_graph(Path::new(&path), courses_only)?; println!("Exported graph to {path}");