Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Brijesh committed Jan 20, 2025
1 parent 19e4837 commit da7bf09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions scripts/plan_extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DataManager from '../src/libs/db2';
import EmailTemplate from '../src/libs/db2/model/emailtemplate';
import { Mailer } from '../src/libs/mailer';
import { substituteFields } from '../src/libs/utils';
import PlanStatusController from '../src/router/controllers_v1/PlanStatusController';

const dm = new DataManager(config);

Expand Down Expand Up @@ -56,18 +57,19 @@ const processExpiredPlans = async (trx) => {
const results = await trx.select().from(Plan.table).where('plan_end_date', '<', new Date());
for (const result of results) {
if (
result.status_id !== 26 &&
result.extension_received_votes !== result.extensionr_received_votes &&
result.extension_status !== PLAN_EXTENSION_STATUS.AWAITING_VOTES
) {
await Plan.update(
trx,
{ id: result.id },
{
status_id: 26,
},
);
}
result.status_id === 26 ||
(PlanStatusController.isPlanActive(result.status_id) &&
result.extension_status === PLAN_EXTENSION_STATUS.AWAITING_VOTES &&
result.extension_received_votes === result.extension_requested_votes)
)
continue;
await Plan.update(
trx,
{ id: result.id },
{
status_id: 26,
},
);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/router/controllers_v1/PlanExtensionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export default class PlanExtensionController {
}
const trx = await db.transaction();
try {
await Plan.update(trx, { id: planId }, { extensionStatus: 3 });
await Plan.update(trx, { id: planId }, { extensionStatus: PLAN_EXTENSION_STATUS.AWAITING_EXTENSION });
trx.commit();
return res.status(200).end();
} catch (error) {
Expand Down

0 comments on commit da7bf09

Please sign in to comment.