-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: count query of sold tickets #6693
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
Conversation
Codecov Report
@@ Coverage Diff @@
## development #6693 +/- ##
==============================================
+ Coverage 65.44% 65.5% +0.06%
==============================================
Files 300 300
Lines 15297 15324 +27
==============================================
+ Hits 10011 10038 +27
Misses 5286 5286
Continue to review full report at Codecov.
|
app/api/attendees.py
Outdated
| order_expiry_time = get_settings()['order_expiry_time'] | ||
| if get_count(db.session.query(TicketHolder.id) | ||
| .filter(TicketHolder.ticket_id == int(data['ticket']), | ||
| TicketHolder.state == 'placed', TicketHolder.deleted_at.is_(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.
placed or completed
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.
@iamareebjamal This is done wrong as TicketHolder has a state which represents its address and not a placed state.It represents a state of address. I have to change this to order and then check for order status
|
@iamareebjamal What command should I run locally to get the hound violations here on my local? |
|
Please add tests as well |
Not sure |
|
I am away from keyboard for today, will update the PR as soon as I get back in the evening |
app/api/attendees.py
Outdated
| .filter(TicketHolder.ticket_id == int(data['ticket']), | ||
| TicketHolder.state == 'placed', TicketHolder.deleted_at.is_(None), | ||
| or_(TicketHolder.state ==' initializing', TicketHolder.created_at < | ||
| datetime.datetime.utcnow()+datetime.timedelta(minutes=order_expiry_time))))\ |
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.
Why check the order expiry time condition? If the order is not created under it, Order is labelled expired. It is not required IMO.
Simply counting the Placed & Completed orders in the before the condition is enough.
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.
We need to count the currently reserved tickets. Or else more tickets than max tickets will be bought. See the discussion in the issue
|
@iamareebjamal Why not to count the placed orders and tickets in here
. here we can event correct the sales statistics all over the web app. As of now we are not showing the sales data and ticket count of Offline Tickets in the dashboard? |
|
We are showing it, but separately. And yes, this is where it will be placed finally. This PR is work in progress |
|
@iamareebjamal For the test, shall I write functions with the multiple status of orders? or seperate. Also while creating attendee I can't change the order status, so shall I run the only create the order or shall I create the attendee.? |
What?
You need to create both |
|
@iamareebjamal - While creating both, 2 orders and 1 attendee is created as in attendee factory an order factory reference is also their.
For the query to test, I am creating a single function with multiple attendees and I am running this query to check that count is valid or not. |
|
@iamareebjamal - Guide me |
Split it and use base |
Create 2 attendees with no order ID, 6 with completed order, 1 with placed, 4 with initializing/initialized and not expired (created_at within order expiry time), 3 with initializing but expired created_at, 5 order status == expired The count should be 11 |
Shall this be done in another PR? as it requires changes everywhere it's used |
|
It requires changes in just one file. attendee factory |
|
Ok got that |
|
@iamareebjamal Review. |
app/api/attendees.py
Outdated
| Order.status == 'completed', | ||
| and_(Order.status == 'initializing', | ||
| Order.created_at + datetime.timedelta( | ||
| minutes=30 + order_expiry_time) > datetime.datetime.utcnow()))).count() |
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.
No, initializing = order expiry time
initialized = 30 minutes + order expiry time
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.
We have a initialized state too🙄
|
@iamareebjamal What i see here is something else. open-event-server/app/api/schema/orders.py Lines 72 to 75 in f27e08d
|
|
That's wrong. There is no pending state in production DB |
Then what is the status getting assigned to pending orders or orders with online payment due? |
cc4d153 to
f2587d9
Compare
|
@iamareebjamal Check, I have created also 2 attendees with the same |
Initialized AFAIK |
|
Waiting for verification of a few things. Will merge then |
|
@iamareebjamal Sure, thanks a lot. It was fun solving this. I am taking other issues now. |
|
They are assigned pending,Also the reason for pending not be present in db
is because it either gets converted into completed after successful payment
or to expired after failing to pay within 30 min of creation.
I dont know what is the purpose of initialized status, as FE is not
labeling any order with initialized.
…On Sat, 28 Dec, 2019, 16:04 Suneet Srivastava, ***@***.***> wrote:
@iamareebjamal <https://github.com/iamareebjamal> Sure, thanks a lot. It
was fun solving this. I am taking other issues now.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6693?email_source=notifications&email_token=AKQMTLWFSJDQSGRVGBJ3ZSTQ24TRTA5CNFSM4J6XTT3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYG6OI#issuecomment-569405241>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKQMTLUQK6XLZXCN7AOYO3TQ24TRTANCNFSM4J6XTT3A>
.
|
|
Alright, please change initialized to pending @codedsun I just confirmed. Don't know how but there are 257 orders in initialized state in production |
|
@iamareebjamal Check now! |
| transaction_id=None, | ||
| paid_via=None, | ||
| is_billing_enabled=False, | ||
| created_at=datetime.datetime.now(datetime.timezone.utc), |
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.
This is the problem. created_at is static - set to the starting time of the server #6703
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.
Making the PR
Fixes #6653
#6653 (comment)
Short description of what this resolves:
Count query of sold tickets. Solution: Calculate only placed orders + initializing orders which were created under order expiry time
Checklist
developmentbranch.