diff --git a/CHANGELOG.md b/CHANGELOG.md index 044753b..e9146a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,14 @@ and this project adheres to a _modified_ form of _[Semantic Versioning][semver]_ [#98]: https://github.com/openlawlibrary/stelae/pull/98 [#97] https://github.com/openlawlibrary/stelae/pull/97 +## [v0.6.6] + +### Fixed + +- Fix commit insertion for multiple data repos of the same type ([#107]) + +[#107]: https://github.com/openlawlibrary/stelae/pull/107 + ## [v0.6.5] ### Added @@ -316,7 +324,8 @@ and this project adheres to a _modified_ form of _[Semantic Versioning][semver]_ ### Removed -[Unreleased]: https://github.com/openlawlibrary/stelae/compare/v0.6.5...HEAD +[Unreleased]: https://github.com/openlawlibrary/stelae/compare/v0.6.6...HEAD +[v0.6.6]: https://github.com/openlawlibrary/stelae/compare/v0.6.5...v0.6.6 [v0.6.5]: https://github.com/openlawlibrary/stelae/compare/v0.6.4...v0.6.5 [v0.6.4]: https://github.com/openlawlibrary/stelae/compare/v0.6.3...v0.6.4 [v0.6.3]: https://github.com/openlawlibrary/stelae/compare/v0.6.2...v0.6.3 diff --git a/Cargo.lock b/Cargo.lock index fd893a0..5cc923f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3400,7 +3400,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stelae" -version = "0.6.5" +version = "0.6.6" dependencies = [ "actix-http", "actix-service", diff --git a/Cargo.toml b/Cargo.toml index d5833dc..f3ae771 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "stelae" description = "A collection of tools in Rust and Python for preserving, authenticating, and accessing laws in perpetuity." -version = "0.6.5" +version = "0.6.6" edition = "2021" readme = "README.md" license = "AGPL-3.0" diff --git a/src/db/models/data_repo_commits/manager.rs b/src/db/models/data_repo_commits/manager.rs index 03c4b88..58d309d 100644 --- a/src/db/models/data_repo_commits/manager.rs +++ b/src/db/models/data_repo_commits/manager.rs @@ -10,13 +10,14 @@ use super::DataRepoCommits; #[async_trait] impl super::TxManager for DatabaseTransaction { - /// Find all authentication commits for a given stele. + /// Find all authentication commits for a given stele and data repository. /// /// # Errors /// Errors if the commits cannot be found. - async fn find_all_auth_commits_for_stele( + async fn find_all_auth_commits_for_stele_and_data_repo( &mut self, stele_id: &str, + data_repo_name: &str, ) -> anyhow::Result> { let query = " SELECT dc.* @@ -24,9 +25,11 @@ impl super::TxManager for DatabaseTransaction { LEFT JOIN publication p ON dc.publication_id = p.id LEFT JOIN stele s ON p.stele = s.name WHERE s.name = $1 + AND p.html_data_repo_name = $2 "; let data_repo_commits = sqlx::query_as::<_, DataRepoCommits>(query) .bind(stele_id) + .bind(data_repo_name) .fetch_all(&mut *self.tx) .await?; Ok(data_repo_commits) diff --git a/src/db/models/data_repo_commits/mod.rs b/src/db/models/data_repo_commits/mod.rs index 9bf2459..511582d 100644 --- a/src/db/models/data_repo_commits/mod.rs +++ b/src/db/models/data_repo_commits/mod.rs @@ -7,10 +7,11 @@ pub mod manager; /// Trait for managing transactional data repo commits. #[async_trait] pub trait TxManager { - /// Find all authentication commits for a given stele. - async fn find_all_auth_commits_for_stele( + /// Find all authentication commits for a given stele and data repository. + async fn find_all_auth_commits_for_stele_and_data_repo( &mut self, stele_id: &str, + data_repo_name: &str, ) -> anyhow::Result>; /// Insert a bulk of data repo commits. async fn insert_bulk(&mut self, data_repo_commits: Vec) -> anyhow::Result<()>; diff --git a/src/history/changes.rs b/src/history/changes.rs index 598070d..43f731c 100644 --- a/src/history/changes.rs +++ b/src/history/changes.rs @@ -693,7 +693,12 @@ async fn insert_commit_hashes_from_auth_repository( let mut data_repo_commits_bulk: Vec = vec![]; let loaded_auth_commits = - data_repo_commits::TxManager::find_all_auth_commits_for_stele(tx, &stele_name).await?; + data_repo_commits::TxManager::find_all_auth_commits_for_stele_and_data_repo( + tx, + &stele_name, + &data_repo.name, + ) + .await?; if loaded_auth_commits.is_empty() { tracing::info!("[{stele_name}] | Inserting commit hashes from the beginning...");