Skip to content

Commit

Permalink
chore: removed unnecessary option for reset to generation
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed May 29, 2024
1 parent 4a5845d commit e23ccba
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
8 changes: 2 additions & 6 deletions src/controllers/audit.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ export const findConflicts = async (req, res) => {

export const resetToGeneration = async (req, res) => {
try {
const { generation, orgUid, includeHomeOrg } = req.body;
const { generation, orgUid } = req.body;

const result = await Audit.resetToGeneration(
generation,
orgUid,
includeHomeOrg,
);
const result = await Audit.resetToGeneration(generation, orgUid);
if (_.isNil(result)) {
throw new Error('query failed');
}
Expand Down
9 changes: 1 addition & 8 deletions src/models/audit/audit.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,11 @@ class Audit extends Model {
return results;
}

static async resetToGeneration(generation, orgUid, includeHomeOrg) {
const homeOrg = Organization.getHomeOrg();
const homeOrgUid = homeOrg?.uid;

static async resetToGeneration(generation, orgUid) {
const where = {
generation: { [Sequelize.Op.gt]: generation },
};

if (!includeHomeOrg && homeOrgUid && orgUid !== homeOrgUid) {
where.orgUid = { [Sequelize.Op.ne]: homeOrgUid };
}

if (orgUid) {
where.orgUid = orgUid;
}
Expand Down
1 change: 0 additions & 1 deletion src/validations/audit.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const auditGetSchema = Joi.object()
export const auditResetToGenerationSchema = Joi.object().keys({
generation: Joi.number(),
orgUid: Joi.string(),
includeHomeOrg: Joi.bool().optional(),
});

export const auditResetToDateSchema = Joi.object().keys({
Expand Down

0 comments on commit e23ccba

Please sign in to comment.