feat: resolved tiny bug secret blind indexing

This commit is contained in:
Akhil Mohan
2024-01-27 20:23:19 +05:30
parent 66d258f02b
commit 8f754d659a
3 changed files with 47 additions and 10 deletions
@@ -58,8 +58,36 @@ export const secretBlindIndexDALFactory = (db: TDbClient) => {
}
};
const findSecretsByProjectId = async (projectId: string, secretIds: string[], tx?: Knex) => {
try {
const docs = await (tx || db)(TableName.Secret)
.leftJoin(
TableName.SecretFolder,
`${TableName.SecretFolder}.id`,
`${TableName.Secret}.folderId`
)
.leftJoin(
TableName.Environment,
`${TableName.Environment}.id`,
`${TableName.SecretFolder}.envId`
)
.where({ projectId })
.whereIn(`${TableName.Secret}.id`, secretIds)
.whereNull("secretBlindIndex")
.select(selectAllTableCols(TableName.Secret))
.select(
db.ref("slug").withSchema(TableName.Environment).as("environment"),
db.ref("projectId").withSchema(TableName.Environment).as("workspace")
);
return docs;
} catch (error) {
throw new DatabaseError({ error, name: "CountOfSecretWillNullSecretBlindIndex" });
}
};
return {
...secretBlindIndexOrm,
findSecretsByProjectId,
countOfSecretsWithNullSecretBlindIndex,
findAllSecretsByProjectId
};