Skip to content

Commit da7bf09

Browse files
author
Brijesh
committed
small fix
1 parent 19e4837 commit da7bf09

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

scripts/plan_extension.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import DataManager from '../src/libs/db2';
55
import EmailTemplate from '../src/libs/db2/model/emailtemplate';
66
import { Mailer } from '../src/libs/mailer';
77
import { substituteFields } from '../src/libs/utils';
8+
import PlanStatusController from '../src/router/controllers_v1/PlanStatusController';
89

910
const dm = new DataManager(config);
1011

@@ -56,18 +57,19 @@ const processExpiredPlans = async (trx) => {
5657
const results = await trx.select().from(Plan.table).where('plan_end_date', '<', new Date());
5758
for (const result of results) {
5859
if (
59-
result.status_id !== 26 &&
60-
result.extension_received_votes !== result.extensionr_received_votes &&
61-
result.extension_status !== PLAN_EXTENSION_STATUS.AWAITING_VOTES
62-
) {
63-
await Plan.update(
64-
trx,
65-
{ id: result.id },
66-
{
67-
status_id: 26,
68-
},
69-
);
70-
}
60+
result.status_id === 26 ||
61+
(PlanStatusController.isPlanActive(result.status_id) &&
62+
result.extension_status === PLAN_EXTENSION_STATUS.AWAITING_VOTES &&
63+
result.extension_received_votes === result.extension_requested_votes)
64+
)
65+
continue;
66+
await Plan.update(
67+
trx,
68+
{ id: result.id },
69+
{
70+
status_id: 26,
71+
},
72+
);
7173
}
7274
};
7375

src/router/controllers_v1/PlanExtensionController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export default class PlanExtensionController {
286286
}
287287
const trx = await db.transaction();
288288
try {
289-
await Plan.update(trx, { id: planId }, { extensionStatus: 3 });
289+
await Plan.update(trx, { id: planId }, { extensionStatus: PLAN_EXTENSION_STATUS.AWAITING_EXTENSION });
290290
trx.commit();
291291
return res.status(200).end();
292292
} catch (error) {

0 commit comments

Comments
 (0)