fix(driver): 修复内置驱动搜索结果重复
This commit is contained in:
2 files changed
+27
-6
No files matched your search
@@ -1,3 +1,5 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::models::connection::DatabaseType;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
@@ -290,12 +292,19 @@ pub fn is_agent_type(db_type: &DatabaseType) -> bool {
|
||||
}
|
||||
|
||||
pub fn driver_store_entries() -> impl Iterator<Item = (&'static str, &'static str)> {
|
||||
entries().iter().flat_map(|entry| {
|
||||
let base = entry.store_visible.then_some((entry.key, entry.label));
|
||||
let profiles =
|
||||
entry.profiles.iter().filter(|profile| profile.store_visible).map(|profile| (profile.key, profile.label));
|
||||
base.into_iter().chain(profiles)
|
||||
})
|
||||
let mut seen = HashSet::new();
|
||||
entries()
|
||||
.iter()
|
||||
.flat_map(move |entry| {
|
||||
let base = entry.store_visible.then_some((entry.key, entry.label));
|
||||
let profiles = entry
|
||||
.profiles
|
||||
.iter()
|
||||
.filter(|profile| profile.store_visible)
|
||||
.map(|profile| (profile.key, profile.label));
|
||||
base.into_iter().chain(profiles)
|
||||
})
|
||||
.filter(move |(key, _)| seen.insert(*key))
|
||||
}
|
||||
|
||||
pub fn label_for_key(agent_key: &str) -> Option<&'static str> {
|
||||
|
||||
Reference in new issue
Block a user