Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
frc4533-lincoln committed Jun 13, 2024
1 parent d1fdd1d commit be846a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
19 changes: 15 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,28 @@ mod page;
mod ranking;
mod web;

use std::{fs, io, num::{NonZeroU16, NonZeroUsize}, sync::Arc};
use std::{
fs, io,
num::{NonZeroU16, NonZeroUsize},
sync::Arc,
};

use axum::{routing::get, Router};
use crawler::Crawler;
use log::LevelFilter;
use lru::LruCache;
use page::Page;
use scraper::Selector;
use tokio::{net::TcpListener, sync::{mpsc, Mutex}};
use lru::LruCache;
use tantivy::{
doc, query::QueryParser, schema::{Field, Schema, FAST, STORED, TEXT}, store::{Compressor, ZstdCompressor}, Index, IndexReader, IndexSettings, Searcher
doc,
query::QueryParser,
schema::{Field, Schema, FAST, STORED, TEXT},
store::{Compressor, ZstdCompressor},
Index, IndexReader, IndexSettings, Searcher,
};
use tokio::{
net::TcpListener,
sync::{mpsc, Mutex},
};

#[derive(Clone)]
Expand Down
14 changes: 11 additions & 3 deletions src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ use axum::{
response::{Html, IntoResponse, Redirect},
};
use once_cell::sync::Lazy;
use tantivy::{collector::{Count, TopDocs}, schema::Value, DocAddress, Score, Searcher, TantivyDocument};
use tantivy::{
collector::{Count, TopDocs},
schema::Value,
DocAddress, Score, Searcher, TantivyDocument,
};
use tera::{Context, Tera};
use tokio::{sync::Mutex, time::Instant};

Expand Down Expand Up @@ -87,8 +91,12 @@ pub async fn results(
let count = searcher.search(&query, &Count).unwrap();

let search_st = Instant::now();
let resultss: Vec<(Score, DocAddress)> =
searcher.search(&query, &TopDocs::with_limit(20).and_offset(params.p.unwrap_or(0))).unwrap();
let resultss: Vec<(Score, DocAddress)> = searcher
.search(
&query,
&TopDocs::with_limit(20).and_offset(params.p.unwrap_or(0)),
)
.unwrap();
let search_time = search_st.elapsed().as_secs_f32() * 1_000.0;

let gather_st = Instant::now();
Expand Down

0 comments on commit be846a0

Please sign in to comment.