-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
feat: modify Dashboard and Filters type to HashMap #1172
Conversation
Signed-off-by: Amirhossein Akhlaghpour <[email protected]>
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request |
Thank you for opening a PR @Mehrbod2002, please feel free to give a look at #1173. The idea behind that PR is to build a foundation that can them simplify the code further in your PR. I'll make some suggestions which you will be able to understand better by glancing through the changes in that PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use #1115 as reference for what we expect as a solution for the issue at hand.
s.extend( | ||
this.into_iter() | ||
.map(|d| (d.dashboard_id.clone().unwrap_or_else(|| d.name.clone()), d)), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do this using HashMap::insert
s, with dashboard_id
as always the key!
s.retain(|_, d| d.dashboard_id != dashboard.dashboard_id); | ||
s.insert( | ||
dashboard | ||
.dashboard_id | ||
.clone() | ||
.unwrap_or(dashboard.name.clone()), | ||
dashboard.clone(), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a simple insert will work? Insert is equivalent to an update in the case of existing keys.
.iter() | ||
.find(|d| { | ||
d.dashboard_id == Some(dashboard_id.to_string()) | ||
&& d.user_id == Some(user_id.to_string()) | ||
d.1.dashboard_id == Some(dashboard_id.to_string()) | ||
&& d.1.user_id == Some(user_id.to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do this with a simple HashMap::get
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar suggestions here
Closing due to inactivity |
Fixes #1171 .