Compare commits
No commits in common. "ffe770b35596751656c53b0b64d11a6b81294dcc" and "a3a3ff8414d091007d4ad5947af2ba0bc267ed58" have entirely different histories.
ffe770b355
...
a3a3ff8414
3 changed files with 9 additions and 55 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -3858,7 +3858,6 @@ dependencies = [
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"miette",
|
"miette",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"rapidfuzz",
|
|
||||||
"rapidhash",
|
"rapidhash",
|
||||||
"rayon",
|
"rayon",
|
||||||
"resvg 0.45.1",
|
"resvg 0.45.1",
|
||||||
|
@ -5344,12 +5343,6 @@ version = "1.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f93e7e49bb0bf967717f7bd674458b3d6b0c5f48ec7e3038166026a69fc22223"
|
checksum = "f93e7e49bb0bf967717f7bd674458b3d6b0c5f48ec7e3038166026a69fc22223"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rapidfuzz"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "270e04e5ea61d40841942bb15e451c29ee1618637bcf97fc7ede5dd4a9b1601b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rapidhash"
|
name = "rapidhash"
|
||||||
version = "4.0.0"
|
version = "4.0.0"
|
||||||
|
|
|
@ -35,7 +35,6 @@ rayon = "1.11.0"
|
||||||
resvg = "0.45.1"
|
resvg = "0.45.1"
|
||||||
image = "0.25.8"
|
image = "0.25.8"
|
||||||
rapidhash = "4.0.0"
|
rapidhash = "4.0.0"
|
||||||
rapidfuzz = "0.5.0"
|
|
||||||
# femtovg = { version = "0.16.0", features = ["wgpu"] }
|
# femtovg = { version = "0.16.0", features = ["wgpu"] }
|
||||||
# wgpu = "26.0.1"
|
# wgpu = "26.0.1"
|
||||||
# mupdf = "0.5.0"
|
# mupdf = "0.5.0"
|
||||||
|
|
|
@ -14,7 +14,6 @@ use cosmic::{
|
||||||
Element, Task,
|
Element, Task,
|
||||||
};
|
};
|
||||||
use miette::{IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use rapidfuzz::distance::levenshtein;
|
|
||||||
use sqlx::{pool::PoolConnection, Sqlite, SqlitePool};
|
use sqlx::{pool::PoolConnection, Sqlite, SqlitePool};
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
||||||
|
@ -571,52 +570,15 @@ impl<'a> Library {
|
||||||
&self,
|
&self,
|
||||||
query: String,
|
query: String,
|
||||||
) -> Vec<ServiceItem> {
|
) -> Vec<ServiceItem> {
|
||||||
let mut items: Vec<ServiceItem> = self
|
let song1 = Song {
|
||||||
.song_library
|
title: "Death Was Arrested".to_string(),
|
||||||
.items
|
..Default::default()
|
||||||
.iter()
|
};
|
||||||
.filter(|song| song.title.contains(&query))
|
let song2 = Song {
|
||||||
.map(|song| song.to_service_item())
|
title: "Smelly_Belly".to_string(),
|
||||||
.collect();
|
..Default::default()
|
||||||
let videos: Vec<ServiceItem> = self
|
};
|
||||||
.video_library
|
vec![ServiceItem::from(&song1), ServiceItem::from(&song2)]
|
||||||
.items
|
|
||||||
.iter()
|
|
||||||
.filter(|vid| vid.title.contains(&query))
|
|
||||||
.map(|vid| vid.to_service_item())
|
|
||||||
.collect();
|
|
||||||
let images: Vec<ServiceItem> = self
|
|
||||||
.image_library
|
|
||||||
.items
|
|
||||||
.iter()
|
|
||||||
.filter(|image| image.title.contains(&query))
|
|
||||||
.map(|image| image.to_service_item())
|
|
||||||
.collect();
|
|
||||||
let presentations: Vec<ServiceItem> = self
|
|
||||||
.presentation_library
|
|
||||||
.items
|
|
||||||
.iter()
|
|
||||||
.filter(|pres| pres.title.contains(&query))
|
|
||||||
.map(|pres| pres.to_service_item())
|
|
||||||
.collect();
|
|
||||||
items.extend(videos);
|
|
||||||
items.extend(images);
|
|
||||||
items.extend(presentations);
|
|
||||||
let mut items: Vec<(usize, ServiceItem)> = items
|
|
||||||
.into_iter()
|
|
||||||
.map(|item| {
|
|
||||||
(
|
|
||||||
levenshtein::distance(
|
|
||||||
query.bytes(),
|
|
||||||
item.title.bytes(),
|
|
||||||
),
|
|
||||||
item,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
items.sort_by(|a, b| a.0.cmp(&b.0));
|
|
||||||
items.into_iter().map(|item| item.1).collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn update_item<C: Content>(self, item: C) -> Task<Message> {
|
// fn update_item<C: Content>(self, item: C) -> Task<Message> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue