adjustment: removed artificial limiting of pit versions

This commit is contained in:
Sheen Capadngan
2024-06-04 23:46:02 +08:00
parent 68a30f4212
commit f21a13f388
5 changed files with 11 additions and 31 deletions
+2 -11
View File
@@ -72,7 +72,7 @@ type TSecretServiceFactoryDep = {
secretDAL: TSecretDALFactory;
secretTagDAL: TSecretTagDALFactory;
secretVersionDAL: TSecretVersionDALFactory;
projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus" | "findProjectBySlug" | "findById">;
projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus" | "findProjectBySlug">;
projectEnvDAL: Pick<TProjectEnvDALFactory, "findOne">;
folderDAL: Pick<
TSecretFolderDALFactory,
@@ -1354,16 +1354,7 @@ export const secretServiceFactory = ({
);
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
const { pitVersionLimit } = await projectDAL.findById(folder.projectId);
const computedQueryLimit = Math.min(pitVersionLimit - offset, limit);
if (offset > pitVersionLimit || computedQueryLimit <= 0) {
return [];
}
const secretVersions = await secretVersionDAL.find(
{ secretId },
{ offset, limit: computedQueryLimit, sort: [["createdAt", "desc"]] }
);
const secretVersions = await secretVersionDAL.find({ secretId }, { offset, limit, sort: [["createdAt", "desc"]] });
return secretVersions;
};