Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Int from Dev #1324

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading