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

feat: modify Dashboard and Filters type to HashMap #1172

Closed
wants to merge 1 commit into from

Conversation

Mehrbod2002
Copy link

Fixes #1171 .

Copy link
Contributor

github-actions bot commented Feb 7, 2025

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@de-sh
Copy link
Contributor

de-sh commented Feb 7, 2025

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.

Copy link
Contributor

@de-sh de-sh left a 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.

Comment on lines +176 to +179
s.extend(
this.into_iter()
.map(|d| (d.dashboard_id.clone().unwrap_or_else(|| d.name.clone()), d)),
);
Copy link
Contributor

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::inserts, with dashboard_id as always the key!

Comment on lines +186 to +193
s.retain(|_, d| d.dashboard_id != dashboard.dashboard_id);
s.insert(
dashboard
.dashboard_id
.clone()
.unwrap_or(dashboard.name.clone()),
dashboard.clone(),
);
Copy link
Contributor

@de-sh de-sh Feb 7, 2025

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.

Comment on lines 205 to +208
.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())
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar suggestions here

@de-sh
Copy link
Contributor

de-sh commented Feb 19, 2025

Closing due to inactivity

@de-sh de-sh closed this Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Vec<item> with HashMap<id, item> for filter and dashboard listing
2 participants