Skip to content
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
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 5 additions & 2 deletions src/db/models/data_repo_commits/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ 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<Vec<DataRepoCommits>> {
let query = "
SELECT dc.*
FROM data_repo_commits dc
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)
Expand Down
5 changes: 3 additions & 2 deletions src/db/models/data_repo_commits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<DataRepoCommits>>;
/// Insert a bulk of data repo commits.
async fn insert_bulk(&mut self, data_repo_commits: Vec<DataRepoCommits>) -> anyhow::Result<()>;
Expand Down
7 changes: 6 additions & 1 deletion src/history/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,12 @@ async fn insert_commit_hashes_from_auth_repository(
let mut data_repo_commits_bulk: Vec<DataRepoCommits> = 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...");
Expand Down
Loading