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

feat: Expire initializing attendees automatically #7050

Merged
merged 3 commits into from
Jun 6, 2020

Conversation

iamareebjamal
Copy link
Member

@iamareebjamal iamareebjamal commented Jun 6, 2020

Currently, this is handled through Order List and Order GET API which is really bad. It should instead be handled through scheduled job like pending tickets are handled

@auto-label auto-label bot added the feature label Jun 6, 2020
status='pending',
created_at=datetime.datetime.now(timezone.utc) - timedelta(minutes=15),
)
attendees_new = AttendeeSubFactory.create_batch(2, order=order_new)

Choose a reason for hiding this comment

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

local variable 'attendees_new' is assigned to but never used

status='pending',
created_at=datetime.datetime.now(timezone.utc) - timedelta(minutes=45),
)
attendees_old = AttendeeSubFactory.create_batch(3, order=order_old)

Choose a reason for hiding this comment

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

local variable 'attendees_old' is assigned to but never used

assert len(order_new.ticket_holders) == 2


def test_expire_pending_tickets(db):

Choose a reason for hiding this comment

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

redefinition of unused 'db' from line 12

)
attendees_old = AttendeeSubFactory.create_batch(3, order=order_old)
order_new = OrderSubFactory()
attendees_new = AttendeeSubFactory.create_batch(2, order=order_new)

Choose a reason for hiding this comment

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

local variable 'attendees_new' is assigned to but never used

created_at=datetime.datetime.now(timezone.utc)
- timedelta(minutes=order_expiry_time)
)
attendees_old = AttendeeSubFactory.create_batch(3, order=order_old)

Choose a reason for hiding this comment

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

local variable 'attendees_old' is assigned to but never used

assert ticket_holder != None


def test_delete_ticket_holders_with_no_order_id(db):

Choose a reason for hiding this comment

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

redefinition of unused 'db' from line 12

attendee_id = attendee.id
delete_ticket_holders_no_order_id()
ticket_holder = TicketHolder.query.get(attendee_id)
assert ticket_holder != None

Choose a reason for hiding this comment

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

comparison to None should be 'if cond is not None:'

test_ticket_holder = AttendeeFactory()
test_ticket_holder.event = test_event
test_ticket_holder.order = test_order
def test_delete_ticket_holder_with_valid_order_id(db):

Choose a reason for hiding this comment

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

redefinition of unused 'db' from line 12

attendee_id = attendee.id
delete_ticket_holders_no_order_id()
ticket_holder = TicketHolder.query.get(attendee_id)
assert ticket_holder != None

Choose a reason for hiding this comment

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

comparison to None should be 'if cond is not None:'


test_event = EventFactoryBasic(state='published')
def test_delete_ticket_holder_created_currently(db):
"""Method to test not deleting ticket holders with no order id but created within expiry time"""

Choose a reason for hiding this comment

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

line too long (100 > 90 characters)

@iamareebjamal iamareebjamal changed the title feat: Expire initializing tickets automatically feat: Expire initializing attendees automatically Jun 6, 2020
TicketFeesFactory(service_fee=10.23, maximum_fee=11)

test_event = EventFactoryBasic(state='published')
def test_delete_ticket_holder_created_currently(db):

Choose a reason for hiding this comment

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

redefinition of unused 'db' from line 12

from tests.factories.event_invoice import EventInvoiceFactory
from tests.factories.order import OrderFactory
from tests.factories.event_invoice import EventInvoiceFactory, EventInvoiceSubFactory
from tests.factories.order import OrderFactory, OrderSubFactory

Choose a reason for hiding this comment

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

'tests.factories.order.OrderFactory' imported but unused

from tests.factories.event import EventFactoryBasic
from tests.factories.event_invoice import EventInvoiceFactory
from tests.factories.order import OrderFactory
from tests.factories.event_invoice import EventInvoiceFactory, EventInvoiceSubFactory

Choose a reason for hiding this comment

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

'tests.factories.event_invoice.EventInvoiceFactory' imported but unused

from tests.all.integration.utils import OpenEventLegacyTestCase
from tests.factories.attendee import AttendeeFactory
from tests.factories.attendee import (

Choose a reason for hiding this comment

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

'tests.factories.attendee.AttendeeFactory' imported but unused

db.session.commit()
order_expiry_time = get_settings()['order_expiry_time']
TicketHolder.query.filter(
TicketHolder.order_id == None,

Choose a reason for hiding this comment

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

comparison to None should be 'if cond is None:'

db.session.commit()
except:

Choose a reason for hiding this comment

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

Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.
do not use bare 'except'

order_expiry_time = get_settings()['order_expiry_time']
query = db.session.query(Order.id).filter(
Order.status == 'initializing',
Order.paid_via == None,

Choose a reason for hiding this comment

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

comparison to None should be 'if cond is None:'

@codecov
Copy link

codecov bot commented Jun 6, 2020

Codecov Report

Merging #7050 into development will increase coverage by 0.01%.
The diff coverage is 82.05%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #7050      +/-   ##
===============================================
+ Coverage        61.15%   61.17%   +0.01%     
===============================================
  Files              260      260              
  Lines            12881    12884       +3     
===============================================
+ Hits              7878     7882       +4     
+ Misses            5003     5002       -1     
Impacted Files Coverage Δ
app/api/helpers/scheduled_jobs.py 50.00% <82.05%> (+1.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98aca7d...77d97c9. Read the comment docs.

@niranjan94
Copy link
Member

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- tests/all/integration/api/helpers/test_scheduled_jobs.py  3
         

See the complete overview on Codacy

@iamareebjamal iamareebjamal merged commit 98e6c5c into fossasia:development Jun 6, 2020
@iamareebjamal iamareebjamal deleted the expire-order-init branch June 6, 2020 04:36
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Jun 6, 2020

This pull request introduces 1 alert when merging 77d97c9 into 98aca7d - view on LGTM.com

new alerts:

  • 1 for Testing equality to None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants