Skip to content

Made search collection name use the cms hash #1333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pgml-dashboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ yaml-rust = "0.4"
zoomies = { git="https://github.com/HyperparamAI/zoomies.git", branch="master" }
ws = { package = "rocket_ws", git = "https://github.com/SergioBenitez/Rocket" }
futures = "0.3.29"

[build-dependencies]
glob = "*"
19 changes: 17 additions & 2 deletions pgml-dashboard/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use glob::glob;
use std::collections::BTreeSet;
use std::fs::read_to_string;
use std::hash::Hasher;
use std::path::PathBuf;
use std::process::Command;

fn main() {
Expand Down Expand Up @@ -27,9 +31,11 @@ fn main() {

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

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

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

println!("cargo:rustc-env=CSS_VERSION={css_version}");
println!("cargo:rustc-env=JS_VERSION={js_version}");
let files_paths = glob("./../pgml-cms/**/*.md")
.expect("Failed to read pgml-cms directory")
.map(|p| p.unwrap())
.collect::<BTreeSet<PathBuf>>();
let mut hasher = std::hash::DefaultHasher::new();
for path in files_paths {
let contents = read_to_string(path.clone()).expect("Error reading file");
hasher.write(&contents.into_bytes());
}
let cms_hash = hasher.finish();
println!("cargo:rustc-env=CMS_HASH={cms_hash}");
}
2 changes: 1 addition & 1 deletion pgml-dashboard/src/utils/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ pub struct SiteSearch {
impl SiteSearch {
pub async fn new() -> anyhow::Result<Self> {
let collection = pgml::Collection::new(
"hypercloud-site-search-c-2",
env!("CMS_HASH"),
Some(
std::env::var("SITE_SEARCH_DATABASE_URL")
.context("Please set the `SITE_SEARCH_DATABASE_URL` environment variable")?,
Expand Down