♻️ update

This commit is contained in:
JMARyA 2025-02-10 09:12:17 +01:00
parent 9f95060806
commit e9d9ac4d9a
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 55 additions and 22 deletions

View file

@ -300,13 +300,26 @@ 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)> =
pub async fn get_documents_of_day(
day: NaiveDate,
domain: Option<&str>,
) -> HashMap<String, Vec<String>> {
let res: Vec<(String, String)> = if let Some(domain) = domain {
sqlx::query_as(
"SELECT domain, path FROM document_index WHERE version = $1 WHERE domain = $2",
)
.bind(day)
.bind(domain)
.fetch_all(get_pg!())
.await
.unwrap()
} else {
sqlx::query_as("SELECT domain, path FROM document_index WHERE version = $1")
.bind(day)
.fetch_all(get_pg!())
.await
.unwrap();
.unwrap()
};
let mut ret = HashMap::new();