PIT: fix blocker for deep rollbacks

This commit is contained in:
carlosmonastyrski
2025-05-21 09:08:12 -03:00
parent 44aa743d56
commit 2493bbbc97
8 changed files with 336 additions and 216 deletions
@@ -294,12 +294,11 @@ export const folderCommitDALFactory = (db: TDbClient) => {
folderId?: string;
envId?: string;
startCommitId?: string;
endCommitId: string;
endCommitId?: string;
tx?: Knex;
}): Promise<TFolderCommits[]> => {
try {
const docs = await (tx || db.replicaNode())(TableName.FolderCommit)
.where("commitId", "<=", endCommitId)
.where((qb) => {
if (envId) {
void qb.where(`${TableName.FolderCommit}.envId`, "=", envId);
@@ -307,6 +306,9 @@ export const folderCommitDALFactory = (db: TDbClient) => {
if (startCommitId) {
void qb.where("commitId", ">=", startCommitId);
}
if (endCommitId) {
void qb.where("commitId", "<=", endCommitId);
}
})
.select(selectAllTableCols(TableName.FolderCommit))
.orderBy("commitId", "desc");
@@ -344,6 +346,20 @@ export const folderCommitDALFactory = (db: TDbClient) => {
}
};
const findPreviousCommitTo = async (folderId: string, commitId: string, tx?: Knex): Promise<TFolderCommits | undefined> => {
try {
const doc = await (tx || db.replicaNode())(TableName.FolderCommit)
.where({ folderId })
.where("commitId", "<=", commitId)
.select(selectAllTableCols(TableName.FolderCommit))
.orderBy("commitId", "desc")
.first();
return doc;
} catch (error) {
throw new DatabaseError({ error, name: "FindPreviousCommitTo" });
}
};
return {
...restOfOrm,
findByFolderId,
@@ -356,6 +372,7 @@ export const folderCommitDALFactory = (db: TDbClient) => {
findLatestEnvCommit,
getEnvNumberOfCommitsSince,
findLatestCommitByFolderIds,
findAllFolderCommitsAfter
findAllFolderCommitsAfter,
findPreviousCommitTo
};
};