-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Correct 'days' attribute not found in expire tickets #5997
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
fix: Correct 'days' attribute not found in expire tickets #5997
Conversation
|
@uds5501 @shreyanshdwivedi @mrsaicharan1 Please review |
Codecov Report
@@ Coverage Diff @@
## development #5997 +/- ##
============================================
Coverage 66.28% 66.28%
============================================
Files 285 285
Lines 13992 13992
============================================
Hits 9274 9274
Misses 4718 4718
Continue to review full report at Codecov.
|
app/api/helpers/scheduled_jobs.py
Outdated
| with app.app_context(): | ||
| db.session.query(Order).filter(Order.status == 'pending', | ||
| (datetime.datetime.today() - Order.created_at).days > 3).\ | ||
| (Order.created_at + datetime.timedelta(days=3)) > datetime.datetime.now()).\ |
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.
Could you explain what this does here? @prateekj117
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.
@prateekj117 just wanna ask, wouldn't order-today be actually negative? Also, please make it >= it will be a better choice
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.
@mrsaicharan1 the main problem was with the days attribute. I don't get it how your condition will solve it.
Refer this for more info on this.
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, using .today() method will take time to be 12:00 of that particular day, we should use .now() instead.
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, your condition seems to be wrong.
Suppose I placed an order yesterday. Won't it be expired?
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.
https://docs.python.org/3/library/datetime.html#timedelta-objects
This would be a better solution
datetime.datetime.now().day - Order.created_at.day > 3
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.
@mrsaicharan1 I read on stackoverflow that there might be a case that python datetime isn't compatible with Sqlalchemy datetime object. So I implemented it this way which shows on stackoverflow that it works. Silly mistake on the opposite equality sign part, will correct it.
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 @prateekj117, there might be cases , but we are comparing difference of days.Difference will never change. But anyways, if you change the sign, your fix works too.
Fixes #5996
Checklist
developmentbranch.Short description of what this resolves:
Corrects 'days' attribute not found in scheduled_jobs.py