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
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion api/namex/VERSION.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.1.36'
__version__ = '1.1.37'
6 changes: 5 additions & 1 deletion api/namex/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,15 @@ def find_existing_name_by_user(cls, user_name_search_string, email):
"""
Gets requests submited by user with given name choice in state draft
"""
current_time = datetime.utcnow()
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 status of request is in pending payment state (payment failed/stuck) within 5 mins
#check if status of request is in draft (payment successful/request in for name examination)
(Request.stateCd == 'DRAFT') | (Request.stateCd == 'PENDING_PAYMENT'),
(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


Expand Down
Loading