Skip to content

Commit 2e08a5d

Browse files
authored
Merge pull request #1324 from CVEProject/dev
Update Int from Dev
2 parents 4d688b9 + cd41522 commit 2e08a5d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/controller/cve-id.controller/cve-id.controller.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,10 @@ async function priorityReservation (year, amount, shortName, orgShortName, reque
455455

456456
// Cve Id Range for 'year' does not exists
457457
if (!result) {
458-
// If there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
458+
// if reservations are not allowed for the current year, or if there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
459+
// We also do not want the auto reservation feature to allow to reserve years in the past.
459460
// Otherwise throw failure
460-
if (daysUntilYear(year) <= 90) {
461+
if (!isYearInPast(year) && daysUntilYear(year) <= 90) {
461462
// Auto reserve the year
462463
const successfullyReservedYear = await reserveYear(year, req)
463464
if (!successfullyReservedYear) {
@@ -544,9 +545,10 @@ async function sequentialReservation (year, amount, shortName, orgShortName, req
544545

545546
// Cve Id Range for 'year' does not exists
546547
if (!result) {
547-
// If there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
548+
// if reservations are not allowed for the current year, or if there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
549+
// We also do not want the auto reserve to work on any year in the past.
548550
// Otherwise throw failure
549-
if (daysUntilYear(year) <= 90) {
551+
if (!isYearInPast(year) && daysUntilYear(year) <= 90) {
550552
// Auto reserve the year
551553
const successfullyReservedYear = await reserveYear(year, req)
552554
if (!successfullyReservedYear) {
@@ -653,9 +655,10 @@ async function nonSequentialReservation (year, amount, shortName, orgShortName,
653655

654656
// Cve Id Range for 'year' does not exists
655657
if (!result) {
656-
// If there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
658+
// if reservations are not allowed for the current year, or if there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
659+
// We also do not want to auto reserve any years in the past.
657660
// Otherwise throw failure
658-
if (daysUntilYear(year) <= 90) {
661+
if (!isYearInPast(year) && daysUntilYear(year) <= 90) {
659662
// Auto reserve the year
660663
const successfullyReservedYear = await reserveYear(year, req)
661664
if (!successfullyReservedYear) {
@@ -983,6 +986,12 @@ function setMinAggregateObj (query) {
983986
]
984987
}
985988

989+
// Function to check if a year is in the past
990+
function isYearInPast (year) {
991+
const currentYear = new Date().getFullYear()
992+
return year < currentYear
993+
}
994+
986995
function daysUntilYear (targetYear) {
987996
// Get today's date
988997
const today = new Date()

0 commit comments

Comments
 (0)