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: Add max_quantity of ticket in order-statistics-event #6735

Merged
merged 2 commits into from Jan 16, 2020

Conversation

codedsun
Copy link
Contributor

…ed order_statistics in event

Fixes #6710
feat: Add max_quantity of ticket in order-statistics-event

Short description of what this resolves:

Changes proposed in this pull request:

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

@auto-label auto-label bot added the feature label Jan 10, 2020
@@ -24,6 +24,7 @@
from app.models.ticket_fee import get_fee
from app.models.ticket_fee import get_maximum_fee
from app.models.ticket_holder import TicketHolder
from app.models.order import Order, OrderTicket

Choose a reason for hiding this comment

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

redefinition of unused 'Order' from line 18

@@ -1,6 +1,6 @@
from flask_rest_jsonapi import ResourceDetail
from marshmallow_jsonapi import fields
from marshmallow_jsonapi.flask import Schema
from marshmallow_jsonapi.flask import Schema, Relationship

Choose a reason for hiding this comment

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

'marshmallow_jsonapi.flask.Relationship' imported but unused

@codecov
Copy link

codecov bot commented Jan 10, 2020

Codecov Report

Merging #6735 into development will decrease coverage by 0.13%.
The diff coverage is 22.72%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #6735      +/-   ##
===============================================
- Coverage        65.39%   65.26%   -0.14%     
===============================================
  Files              300      300              
  Lines            15317    15357      +40     
===============================================
+ Hits             10017    10023       +6     
- Misses            5300     5334      +34
Impacted Files Coverage Δ
app/api/schema/events.py 91.4% <100%> (+0.06%) ⬆️
app/models/event.py 70.7% <13.15%> (-8%) ⬇️
app/api/order_statistics/events.py 48.48% <80%> (+0.04%) ⬆️

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 3ea3814...5696b2a. Read the comment docs.

tickets = fields.Str()
orders = fields.Str()
sales = fields.Str()
# tickets = fields.Method("tickets_count")
Copy link
Contributor Author

@codedsun codedsun Jan 13, 2020

Choose a reason for hiding this comment

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

@iamareebjamal - How do i make the tickets variable of dynamic type like
for when I want to work with GET call of
http://127.0.0.1:5000/v1/users/8/events?page[size]=0&include=order_statistics
the tickets should be of type fields.Dict()

and when I call GET http://127.0.0.1:5000/v1/events/38/order-statistics it should call the function from events model and take that type.

Stucked here!

@iamareebjamal
Copy link
Member

@codedsun Please complete this now

@codecov
Copy link

codecov bot commented Jan 16, 2020

Codecov Report

❗ No coverage uploaded for pull request base (development@d629dc9). Click here to learn what that means.
The diff coverage is 78.26%.

Impacted file tree graph

@@              Coverage Diff               @@
##             development    #6735   +/-   ##
==============================================
  Coverage               ?   65.42%           
==============================================
  Files                  ?      300           
  Lines                  ?    15330           
  Branches               ?        0           
==============================================
  Hits                   ?    10030           
  Misses                 ?     5300           
  Partials               ?        0
Impacted Files Coverage Δ
app/api/helpers/auth.py 67.5% <0%> (ø)
app/api/order_statistics/events.py 48.48% <0%> (ø)
app/api/schema/events.py 91.47% <100%> (ø)
app/api/schema/speakers.py 97.82% <100%> (ø)
app/api/routes.py 100% <100%> (ø)
app/models/speaker.py 94.8% <100%> (ø)
app/models/user_token_blacklist.py 100% <100%> (ø)
app/instance.py 91.3% <50%> (ø)
app/models/event.py 78.36% <60%> (ø)

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 d629dc9...456f2de. Read the comment docs.

@codedsun
Copy link
Contributor Author

@iamareebjamal - Done check

@iamareebjamal
Copy link
Member

Does not filter deleted tickets out

@@ -48,14 +50,16 @@ def tickets_count(self, obj):
Order.event_id == obj_id, Order.status == 'placed').scalar()
completed = db.session.query(func.sum(OrderTicket.quantity.label('sum'))).join(Order.order_tickets).filter(
Order.event_id == obj_id, Order.status == 'completed').scalar()
max = db.session.query(func.sum(Ticket.quantity.label('sum'))).filter(Ticket.event_id == obj_id, Ticket.deleted_at == None).scalar()

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:'
line too long (140 > 120 characters)

@@ -48,14 +50,17 @@ def tickets_count(self, obj):
Order.event_id == obj_id, Order.status == 'placed').scalar()
completed = db.session.query(func.sum(OrderTicket.quantity.label('sum'))).join(Order.order_tickets).filter(
Order.event_id == obj_id, Order.status == 'completed').scalar()
max = db.session.query(func.sum(Ticket.quantity.label('sum'))).filter(Ticket.event_id == obj_id,
Ticket.deleted_at == None).scalar()

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:'

@codedsun
Copy link
Contributor Author

@iamareebjamal - Chck this

@iamareebjamal iamareebjamal changed the title feat: Add max_quantity of ticket in order-statistics-event and includ… feat: Add max_quantity of ticket in order-statistics-event Jan 16, 2020
@iamareebjamal iamareebjamal merged commit 2150e27 into fossasia:development Jan 16, 2020
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.

Remove event-orga endpoint
3 participants