Content-Length: 373744 | pFad | http://github.com/postgresml/postgresml/commit/d81a360d019b248d2bba43b6e98420d9fe7ac2d6

99 Made search collection name use the cms hash (#1333) · postgresml/postgresml@d81a360 · GitHub
Skip to content

Commit d81a360

Browse files
authored
Made search collection name use the cms hash (#1333)
1 parent 35d12bf commit d81a360

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

pgml-dashboard/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ yaml-rust = "0.4"
5252
zoomies = { git="https://github.com/HyperparamAI/zoomies.git", branch="master" }
5353
ws = { package = "rocket_ws", git = "https://github.com/SergioBenitez/Rocket" }
5454
futures = "0.3.29"
55+
56+
[build-dependencies]
57+
glob = "*"

pgml-dashboard/build.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
use glob::glob;
2+
use std::collections::BTreeSet;
13
use std::fs::read_to_string;
4+
use std::hash::Hasher;
5+
use std::path::PathBuf;
26
use std::process::Command;
37

48
fn main() {
@@ -27,9 +31,11 @@ fn main() {
2731

2832
let css_version = read_to_string("static/css/.pgml-bundle").expect("failed to read .pgml-bundle");
2933
let css_version = css_version.trim();
34+
println!("cargo:rustc-env=CSS_VERSION={css_version}");
3035

3136
let js_version = read_to_string("static/js/.pgml-bundle").expect("failed to read .pgml-bundle");
3237
let js_version = js_version.trim();
38+
println!("cargo:rustc-env=JS_VERSION={js_version}");
3339

3440
let status = Command::new("cp")
3541
.arg("static/js/main.js")
@@ -41,6 +47,15 @@ fn main() {
4147
panic!("failed to bundle main.js");
4248
}
4349

44-
println!("cargo:rustc-env=CSS_VERSION={css_version}");
45-
println!("cargo:rustc-env=JS_VERSION={js_version}");
50+
let files_paths = glob("./../pgml-cms/**/*.md")
51+
.expect("Failed to read pgml-cms directory")
52+
.map(|p| p.unwrap())
53+
.collect::<BTreeSet<PathBuf>>();
54+
let mut hasher = std::hash::DefaultHasher::new();
55+
for path in files_paths {
56+
let contents = read_to_string(path.clone()).expect("Error reading file");
57+
hasher.write(&contents.into_bytes());
58+
}
59+
let cms_hash = hasher.finish();
60+
println!("cargo:rustc-env=CMS_HASH={cms_hash}");
4661
}

pgml-dashboard/src/utils/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ pub struct SiteSearch {
12391239
impl SiteSearch {
12401240
pub async fn new() -> anyhow::Result<Self> {
12411241
let collection = pgml::Collection::new(
1242-
"hypercloud-site-search-c-2",
1242+
env!("CMS_HASH"),
12431243
Some(
12441244
std::env::var("SITE_SEARCH_DATABASE_URL")
12451245
.context("Please set the `SITE_SEARCH_DATABASE_URL` environment variable")?,

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgresml/postgresml/commit/d81a360d019b248d2bba43b6e98420d9fe7ac2d6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy