Copilot/refactor for performance optimizations#141
Conversation
Agent-Logs-Url: https://github.com/gfauredev/LogOut/sessions/8e1eb795-b16c-4941-8b92-f530e7c4648e Co-authored-by: gfauredev <19304085+gfauredev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gfauredev/LogOut/sessions/8e1eb795-b16c-4941-8b92-f530e7c4648e Co-authored-by: gfauredev <19304085+gfauredev@users.noreply.github.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughConsolidated URL resolution and CSV parsing in utilities, optimised percent-decoding allocations, and small refactors in models: inlined average computation and replaced conditional logic with a match for exercise tagging. No public signatures were changed. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
📊 Coverage ReportLines: 3756/4996 (75.18014411529224%) ⏱️ Tests: 255 tests in 0.476s
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/utils.rs`:
- Around line 59-60: configured_exercise_db_url() currently only rejects empty
strings and may return whitespace-only or unnormalised values; update it to trim
the input (and re-check emptiness) before returning Some so callers never get
whitespace-only URLs, and apply the same trimming/emptiness check to the other
configured_* URL helpers referenced (the other functions around lines 69-70 and
73-85) so all URL single-source-of-truth helpers normalize input consistently
instead of returning raw untrimmed strings.
- Around line 250-255: The parse_csv_ids function currently preserves
surrounding whitespace which leads to IDs like " Barbell_Squat" failing
downstream; update parse_csv_ids to trim each split token (use id.trim()) before
converting to String and ensure you filter out empty strings after trimming, and
confirm callers such as StartSession consume the returned trimmed IDs so stored
IDs have no leading/trailing spaces.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d473e091-8320-498b-bea4-704e79026a51
📒 Files selected for processing (3)
src/models/analytics.rssrc/models/mod.rssrc/utils.rs
| configured_exercise_db_url().unwrap_or_else(|| EXERCISE_DB_BASE_URL.to_string()) | ||
| } |
There was a problem hiding this comment.
Harden configured URL sanitisation at the single source of truth.
configured_exercise_db_url() only filters is_empty(), so whitespace-only or unnormalised values can be treated as valid and then break both DB and image base URL consumers. Normalise (or at least trim) before returning Some.
💡 Proposed fix
fn configured_exercise_db_url() -> Option<String> {
#[cfg(target_arch = "wasm32")]
{
web_sys::window()
.and_then(|window| window.local_storage().ok().flatten())
.and_then(|storage| storage.get_item(EXERCISE_DB_URL_STORAGE_KEY).ok().flatten())
- .filter(|url| !url.is_empty())
+ .and_then(|url| {
+ let normalized = normalize_db_url(&url);
+ (!normalized.is_empty()).then_some(normalized)
+ })
}
#[cfg(not(target_arch = "wasm32"))]
{
use crate::services::storage::native_storage;
- native_storage::get_config_value(EXERCISE_DB_URL_STORAGE_KEY).filter(|url| !url.is_empty())
+ native_storage::get_config_value(EXERCISE_DB_URL_STORAGE_KEY).and_then(|url| {
+ let normalized = normalize_db_url(&url);
+ (!normalized.is_empty()).then_some(normalized)
+ })
}
}Also applies to: 69-70, 73-85
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/utils.rs` around lines 59 - 60, configured_exercise_db_url() currently
only rejects empty strings and may return whitespace-only or unnormalised
values; update it to trim the input (and re-check emptiness) before returning
Some so callers never get whitespace-only URLs, and apply the same
trimming/emptiness check to the other configured_* URL helpers referenced (the
other functions around lines 69-70 and 73-85) so all URL single-source-of-truth
helpers normalize input consistently instead of returning raw untrimmed strings.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
📊 Coverage ReportLines: 3757/4997 (75.18511106663999%) ⏱️ Tests: 255 tests in 0.538s
|
This Pull Request…
Engineering Principles
scope is focused (no unrelated dependency updates or formatting)
README’s Engineering PrinciplesCI/CD Readiness
feat/…,fix/…,refactor/…, …dx fmt; cargo fmtnix flake checkssucceeds without warningsdx buildwith necessary platform flags succeedscargo clippy -- -D warnings -W clippy::all -W clippy::pedanticproduces zero warnings
cargo llvm-cov nextest --ignore-filename-regex '(src/components/|\.cargo/registry/|nix/store)'maestro test --headless maestro/webmaestro test --headless maestro/androidSummary by CodeRabbit