Skip to content

Commit

Permalink
Merge pull request #1324 from CVEProject/dev
Browse files Browse the repository at this point in the history
Update Int from Dev
  • Loading branch information
jdaigneau5 authored Jan 15, 2025
2 parents 4d688b9 + cd41522 commit 2e08a5d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/controller/cve-id.controller/cve-id.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,10 @@ async function priorityReservation (year, amount, shortName, orgShortName, reque

// Cve Id Range for 'year' does not exists
if (!result) {
// If there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
// 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.
// We also do not want the auto reservation feature to allow to reserve years in the past.
// Otherwise throw failure
if (daysUntilYear(year) <= 90) {
if (!isYearInPast(year) && daysUntilYear(year) <= 90) {
// Auto reserve the year
const successfullyReservedYear = await reserveYear(year, req)
if (!successfullyReservedYear) {
Expand Down Expand Up @@ -544,9 +545,10 @@ async function sequentialReservation (year, amount, shortName, orgShortName, req

// Cve Id Range for 'year' does not exists
if (!result) {
// If there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
// 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.
// We also do not want the auto reserve to work on any year in the past.
// Otherwise throw failure
if (daysUntilYear(year) <= 90) {
if (!isYearInPast(year) && daysUntilYear(year) <= 90) {
// Auto reserve the year
const successfullyReservedYear = await reserveYear(year, req)
if (!successfullyReservedYear) {
Expand Down Expand Up @@ -653,9 +655,10 @@ async function nonSequentialReservation (year, amount, shortName, orgShortName,

// Cve Id Range for 'year' does not exists
if (!result) {
// If there are less than or equal to 90 days until the end of the year, auto reserve it and move on.
// 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.
// We also do not want to auto reserve any years in the past.
// Otherwise throw failure
if (daysUntilYear(year) <= 90) {
if (!isYearInPast(year) && daysUntilYear(year) <= 90) {
// Auto reserve the year
const successfullyReservedYear = await reserveYear(year, req)
if (!successfullyReservedYear) {
Expand Down Expand Up @@ -983,6 +986,12 @@ function setMinAggregateObj (query) {
]
}

// Function to check if a year is in the past
function isYearInPast (year) {
const currentYear = new Date().getFullYear()
return year < currentYear
}

function daysUntilYear (targetYear) {
// Get today's date
const today = new Date()
Expand Down

0 comments on commit 2e08a5d

Please sign in to comment.