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

fix: if ticket is not available for sale ,don't show event #7443

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion app/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ def query(self, view_kwargs):
:param view_kwargs:
:return:
"""
from app.api.attendees import get_sold_and_reserved_tickets_count
current_time = datetime.now(pytz.utc)
query_ = (
self.session.query(Event)
Expand All @@ -858,7 +859,7 @@ def query(self, view_kwargs):
Event.event_type_id != None,
Event.event_topic_id != None,
Event.event_sub_topic_id != None,
Event.tickets.any(and_(Ticket.deleted_at == None, Ticket.is_hidden == False, Ticket.sales_ends_at > current_time, Ticket.is_available == True)),
Event.tickets.any(and_(Ticket.deleted_at == None, Ticket.is_hidden == False, Ticket.sales_ends_at > current_time, Ticket.quantity > get_sold_and_reserved_tickets_count(Ticket.id))),
Copy link
Member

Choose a reason for hiding this comment

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

Won't work. This is not a python loop, only allowed operations here are sqlalchemy scalar and join type operations

Copy link
Member

Choose a reason for hiding this comment

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

Please verify by running before submitting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's working, I have checked it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have an event, it has two tickets and 1 ticket of each type is sold.then after applying above I edited event and changes ticket number to 1 of both events then the event is not on the front page anymore. Then i changed ticket numbers for one ticket to one and for another ticket to 100. Then event is showing on front page.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, yes, it'll work indeed. But I'll have to check if the query is efficient. Sorry for not noticing Ticket.id instead of ticket.id

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't work, it statically returns all reserved and sold tickets and compares ticket quantity with it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_sold_and_reserved_tickets_count(Ticket.id) what is meaning of passing ticked.id here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all reserved and sold tickets for a ticket ?

Copy link
Member

Choose a reason for hiding this comment

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

It won't work because it expects a ticket ID. Passing Ticket.id just returns all tickets sold count

),
),
)
Expand Down