fix: clippy warnings

This commit is contained in:
chitao1234
2025-09-15 12:03:09 +08:00
committed by Ellie Huxtable
parent 0aedb4ddd9
commit 2ddf9349ef
2 changed files with 22 additions and 32 deletions

View File

@@ -77,12 +77,12 @@ pub fn current_context() -> Context {
}
fn get_session_start_time(session_id: &str) -> Option<i64> {
if let Ok(uuid) = Uuid::parse_str(session_id) {
if let Some(timestamp) = uuid.get_timestamp() {
if let Ok(uuid) = Uuid::parse_str(session_id)
&& let Some(timestamp) = uuid.get_timestamp()
{
let (seconds, nanos) = timestamp.to_unix();
return Some(seconds as i64 * 1_000_000_000 + nanos as i64);
}
}
None
}

View File

@@ -48,6 +48,7 @@ impl SearchEngine for Search {
}
}
#[allow(clippy::too_many_lines)]
async fn fuzzy_search(
engine: &SkimMatcherV2,
state: &SearchState,
@@ -95,36 +96,25 @@ async fn fuzzy_search(
};
if !is_current_session {
let uuid = match uuid::Uuid::parse_str(&context.session) {
Ok(uuid) => uuid,
Err(_) => {
let Ok(uuid) = uuid::Uuid::parse_str(&context.session) else {
log::warn!("failed to parse session id '{}'", context.session);
continue;
}
};
let timestamp = match uuid.get_timestamp() {
Some(timestamp) => timestamp,
None => {
let Some(timestamp) = uuid.get_timestamp() else {
log::warn!(
"failed to get timestamp from uuid '{}'",
uuid.as_hyphenated()
);
continue;
}
};
let (seconds, nanos) = timestamp.to_unix();
let session_start = match time::OffsetDateTime::from_unix_timestamp_nanos(
seconds as i128 * 1_000_000_000 + nanos as i128,
) {
Ok(session_start) => session_start,
Err(_) => {
let Ok(session_start) = time::OffsetDateTime::from_unix_timestamp_nanos(
i128::from(seconds) * 1_000_000_000 + i128::from(nanos),
) else {
log::warn!(
"failed to create OffsetDateTime from second: {}, nanosecond: {}",
seconds,
nanos
"failed to create OffsetDateTime from second: {seconds}, nanosecond: {nanos}"
);
continue;
}
};
if history.timestamp >= session_start {