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

🐛 Capacity counts are drifting from what is expected; unknown cause #321

Open
grablair opened this issue Dec 18, 2024 · 4 comments
Open
Labels
bug Something isn't working

Comments

@grablair
Copy link
Contributor

Note

Please stick to the template and provide as much detail as possible to help us diagnose and fix the issue.
Low effort bug reports will be closed.

Describe the bug
I'm consistently seeing capacity counts that don't match up with reality:

SELECT ca.name, ca.used_capacity, count(*) AS expected_used_capacity
    FROM capacity_assignments ca 
        JOIN ticket_capacity_assignments tca ON tca.capacity_assignment_id = ca.id 
        JOIN attendees a ON a.ticket_id = tca.ticket_id 
        JOIN orders o ON o.id = a.order_id 
    WHERE ca.event_id = 9 
        AND a.status = 'ACTIVE' 
        AND (o.status = 'COMPLETED' OR (o.status = 'RESERVED' AND o.reserved_until > now()))
        AND a.deleted_at IS NULL 
    GROUP BY ca.name, ca.used_capacity
    ORDER BY ca.name;

  name   | used_capacity | expected_used_capacity
---------+---------------+------------------------
 12/12@7 |            22 |                     11
 12/13@7 |            23 |                     27
 12/14@1 |            24 |                     22
 12/14@4 |            36 |                     24
 12/15@1 |            17 |                     19
 12/15@4 |            15 |                     15
 12/19@7 |            32 |                     39
 12/20@7 |            30 |                     30
 12/21@1 |            36 |                     36
 12/21@4 |            40 |                     50
 12/22@1 |            38 |                     40
 12/22@4 |            21 |                     21

To Reproduce
Steps to reproduce the behavior:

Unknown; need to investigate

Expected behavior
I expect the capacity counts to match up to the number of non-deleted attendees who have either:

  1. Purchased a ticket that has not been cancelled, or
  2. Have started the checkout process which has not yet expired

Screenshots
See graph above.

Logs
N/A

Desktop (please complete the following information):
N/A, this is server-side

Hi.Events Version and platform
DigitalOcean v0.8.0

@grablair grablair added the bug Something isn't working label Dec 18, 2024
@grablair grablair changed the title 🐛 Capacity counts are 🐛 Capacity counts are drifting from what is expected; unknown cause Dec 18, 2024
@daveearley
Copy link
Contributor

daveearley commented Dec 19, 2024

Hi @grablair,

Thanks for reporting this! Let me do some investigation and get back to you.

Update: I've found two bugs related to capacity assignments. I'll have a fix out ASAP.

@daveearley
Copy link
Contributor

There was an issue where cancelling an order would not update the capacity assignment's used quantity. I've released a fix for that, and I'm still investigating to see if there are other issues.

Did you cancel a lot of orders?

@grablair
Copy link
Contributor Author

grablair commented Dec 19, 2024

No, we have very few cancelled orders. Maybe 4, total.

We have shifted a modest number of attendees from one day to another (indicated by separate tickets), and we have created a significant amount of attendees manually via the CreateAttendeeAction API.

And thank you!

@daveearley
Copy link
Contributor

Thanks for the additional information. I’ve identified and resolved all the issues. However, the capacity assignments in the database need to be updated to reflect the correct numbers. I’ll work on an SQL query to handle this update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants