Skip to content

Commit

Permalink
Fix task , add beat to container start
Browse files Browse the repository at this point in the history
  • Loading branch information
Suryansh5545 committed Aug 5, 2023
1 parent 011ba46 commit dac3852
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
37 changes: 23 additions & 14 deletions apps/transactions/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,28 @@

@shared_task
def check_all_transaction_status():
transactions = Transaction.objects.all
transactions = Transaction.objects.all()
for transaction in transactions:
payment = client.payment.fetch(transaction.order_id)
if payment["status"] != transaction.payment_status:
transaction.payment_status = payment["status"]
order = client.order.fetch(transaction.order_id)
if order["status"] == "paid":
payment = client.order.payments(transaction.order_id)
payment_status = payment["items"][0]["status"]
if payment_status != transaction.payment_status:
transaction.payment_status = payment_status
transaction.save()
ticket = Ticket.objects.get(transaction_id=transaction)
if ticket.is_active == False and transaction.payment_status == "captured":
ticket.is_active = True
if ticket.ticket_image_generated == False:
generate_ticket_image(ticket)
ticket.save()
elif ticket.is_active == True and transaction.payment_status != "captured":
ticket.is_active = False
ticket.save()
else:
transaction.payment_status = order["status"]
transaction.save()
ticket = Ticket.objects.get(transaction_id=transaction)
if ticket.is_active == False and transaction.payment_status == "captured":
ticket.is_active = True
if ticket.ticket_image_generated == False:
generate_ticket_image(ticket)
ticket.save()
elif ticket.is_active == True and transaction.payment_status != "captured":
ticket.is_active = False
ticket.save()

ticket = Ticket.objects.get(transaction_id=transaction)
if ticket.is_active == True:
ticket.is_active = False
ticket.save()
2 changes: 1 addition & 1 deletion docker/dev/celery/container-start.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
cd /code && \
celery -A ticketify worker --loglevel=INFO
celery -A ticketify worker --beat --loglevel=INFO

0 comments on commit dac3852

Please sign in to comment.