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

18515_Unblock_duplicate_after_5min_interval #1484

Merged
merged 3 commits into from
Nov 14, 2023

Conversation

Rajandeep98
Copy link
Contributor

*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).

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),
Copy link
Collaborator

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?

Copy link
Collaborator

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

Copy link
Collaborator

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()
Copy link
Collaborator

@bolyachevets bolyachevets Nov 9, 2023

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

Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

Copy link
Collaborator

@ozamani9gh ozamani9gh left a 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()
Copy link
Collaborator

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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

Copy link

sonarcloud bot commented Nov 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ozamani9gh ozamani9gh merged commit 4c9371d into bcgov:main Nov 14, 2023
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants