Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow freely setting project thresholds #25

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions src/types/user_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ pub struct UserSettings {

impl UserSettings {
/// Sets the threshold for the given risk domain.
pub fn set_threshold(
&mut self,
project_id: String,
name: String,
threshold: i32,
action: String,
) {
pub fn set_threshold(&mut self, project_id: String, name: String, threshold: Threshold) {
// log::debug!("Retrieving user settings for project: {}", project_id);
let mut thresholds = self
.projects
Expand All @@ -56,14 +50,7 @@ impl UserSettings {
});

if let Setting::Project(ref mut t) = thresholds {
t.thresholds.insert(
name,
Threshold {
action,
active: (threshold > 0),
threshold: (threshold as f32) / 100.0,
},
);
t.thresholds.insert(name, threshold);
}

self.projects.insert(project_id, thresholds);
Expand Down