-
Notifications
You must be signed in to change notification settings - Fork 47
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
18515_Unblock_duplicate_after_5min_interval #1484
Conversation
api/namex/models/request.py
Outdated
existing_nr = db.session.query(Request). \ | ||
join(Applicant, and_(Applicant.nrId == Request.id)). \ | ||
filter( | ||
Applicant.emailAddress == email, | ||
(Request.stateCd == 'DRAFT') | (Request.stateCd == 'PENDING_PAYMENT') , | ||
#check if the request is being made within 5 minutes, if time >= 5 minutes, it will let the user create a new request with same name otherwise it will give the error message to prevent accidental duplicates and accidental double payments for them. | ||
Request.submittedDate >= current_time - timedelta(minutes=5), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am curious, why is it 5 minutes exactly and not 1 or 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they want to allow for users that error out to resend the exact same name, after a 5 minute window. Waiting on Joshua to approve this 5 minutes. we may lower the time limit. we just dont want users to DOUBLE Process the exact same Name Request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our data shows many duplicate NR submissions within 1-2 minutes. We're making a change to fix duplicates without blocking others. A 5-minute window seems reasonable to us.
existing_nr = db.session.query(Request). \ | ||
join(Applicant, and_(Applicant.nrId == Request.id)). \ | ||
filter( | ||
Applicant.emailAddress == email, | ||
(Request.stateCd == 'DRAFT') | (Request.stateCd == 'PENDING_PAYMENT') , | ||
#check if the request is being made within 5 minutes, if time >= 5 minutes, it will let the user create a new request with same name otherwise it will give the error message to prevent accidental duplicates and accidental double payments for them. | ||
Request.submittedDate >= current_time - timedelta(minutes=5), | ||
(Request.nameSearch == ('('+user_name_search_string+')')) | ( Request.nameSearch == user_name_search_string )). \ | ||
one_or_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, this method throws an exception if more than one row is returned: https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Query.one_or_none - maybe i don't understand the logic, but can we have a situation where 2 intentional duplicates exist and we are applying for more - would not this throw an exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please fix that exception, Rajan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated code to check on only for pending payment state if request stuck for payment about 5 mins or more then user can send in another request, once nr is fully completed with payment then system will not allow duplicates not even intentional ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please look at my comments
existing_nr = db.session.query(Request). \ | ||
join(Applicant, and_(Applicant.nrId == Request.id)). \ | ||
filter( | ||
Applicant.emailAddress == email, | ||
(Request.stateCd == 'DRAFT') | (Request.stateCd == 'PENDING_PAYMENT') , | ||
#check if the request is being made within 5 minutes, if time >= 5 minutes, it will let the user create a new request with same name otherwise it will give the error message to prevent accidental duplicates and accidental double payments for them. | ||
Request.submittedDate >= current_time - timedelta(minutes=5), | ||
(Request.nameSearch == ('('+user_name_search_string+')')) | ( Request.nameSearch == user_name_search_string )). \ | ||
one_or_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please fix that exception, Rajan
existing_nr = db.session.query(Request). \ | ||
join(Applicant, and_(Applicant.nrId == Request.id)). \ | ||
filter( | ||
Applicant.emailAddress == email, | ||
(Request.stateCd == 'DRAFT') | (Request.stateCd == 'PENDING_PAYMENT') , | ||
#check if the request is being made within 5 minutes, if time >= 5 minutes, it will let the user create a new request with same name otherwise it will give the error message to prevent accidental duplicates and accidental double payments for them. | ||
Request.submittedDate >= current_time - timedelta(minutes=5), | ||
(Request.nameSearch == ('('+user_name_search_string+')')) | ( Request.nameSearch == user_name_search_string )). \ | ||
one_or_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
Kudos, SonarCloud Quality Gate passed!
|
*Issue #18515 - URGENT HOTFIX - PENDING_PAYMENT STATUS INCORRECT - Submitting intentional duplicate names blocked
bcgov/entity#18515
Description of changes:
Updating the interval to prevent accidental duplicates and allowing to create intentional duplicate name request after 5 minutes if user needs it.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the namex license (Apache 2.0).