✨ document chrono view
This commit is contained in:
parent
e2b755aeaf
commit
64956bf2f2
4 changed files with 152 additions and 10 deletions
|
@ -1,4 +1,7 @@
|
|||
use std::{collections::HashSet, path::PathBuf};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
blacklist::{check_blacklist, check_blacklist_path},
|
||||
|
@ -9,6 +12,7 @@ use crate::{
|
|||
mod document;
|
||||
mod domain;
|
||||
use based::get_pg;
|
||||
use chrono::NaiveDate;
|
||||
pub use document::Document;
|
||||
pub use domain::*;
|
||||
|
||||
|
@ -292,3 +296,25 @@ pub async fn index_document(doc: &Document) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DocumentIndex {}
|
||||
|
||||
impl DocumentIndex {
|
||||
pub async fn get_documents_of_day(day: NaiveDate) -> HashMap<String, Vec<String>> {
|
||||
let res: Vec<(String, String)> =
|
||||
sqlx::query_as("SELECT domain, path FROM document_index WHERE version = $1")
|
||||
.bind(day)
|
||||
.fetch_all(get_pg!())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut ret = HashMap::new();
|
||||
|
||||
for (domain, path) in res {
|
||||
let d: &mut Vec<String> = ret.entry(domain).or_default();
|
||||
d.push(path);
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue