File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 22from marshmallow_jsonapi .flask import Schema
33from flask_rest_jsonapi import ResourceList
44
5+ from app .api .helpers .utilities import dasherize
56from app .api .bootstrap import api
67from app .models import db
78from app .models .event import Event
@@ -23,6 +24,7 @@ class AdminSalesByEventsSchema(Schema):
2324 class Meta :
2425 type_ = 'admin-sales-by-events'
2526 self_view = 'v1.admin_sales_by_events'
27+ inflect = dasherize
2628
2729 id = fields .String ()
2830 name = fields .String ()
Original file line number Diff line number Diff line change 22from marshmallow_jsonapi .flask import Schema
33from flask_rest_jsonapi import ResourceList
44from sqlalchemy import func
5+ from app .api .helpers .utilities import dasherize
56
67from app .api .bootstrap import api
78from app .models import db
@@ -34,6 +35,7 @@ class AdminSalesByLocationSchema(Schema):
3435 class Meta :
3536 type_ = 'admin-sales-by-location'
3637 self_view = 'v1.admin_sales_by_location'
38+ inflect = dasherize
3739
3840 id = fields .String ()
3941 location_name = fields .String ()
@@ -63,9 +65,12 @@ class AdminSalesByLocationList(ResourceList):
6365 """
6466
6567 def query (self , _ ):
66- locations = self .session .query (Event .location_name ) \
67- .group_by (Event .location_name ) \
68- .cte ()
68+ locations = self .session .query (
69+ Event .location_name ,
70+ Event .location_name .label ('id' )) \
71+ .group_by (Event .location_name ) \
72+ .filter (Event .location_name .isnot (None )) \
73+ .cte ()
6974
7075 pending = sales_per_location_by_status ('pending' )
7176 completed = sales_per_location_by_status ('completed' )
Original file line number Diff line number Diff line change 22from marshmallow_jsonapi .flask import Schema
33from flask_rest_jsonapi import ResourceList
44
5+ from app .api .helpers .utilities import dasherize
56from app .api .bootstrap import api
67from app .models import db
78from app .models .event import Event
@@ -25,6 +26,7 @@ class AdminSalesByOrganizersSchema(Schema):
2526 class Meta :
2627 type_ = 'admin-sales-by-organizers'
2728 self_view = 'v1.admin_sales_by_organizers'
29+ inflect = dasherize
2830
2931 id = fields .String ()
3032 first_name = fields .String ()
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def status_summary(orders, status):
1111 """
1212 return {
1313 'sales_total' : sum ([o .amount for o in orders if o .status == status ]),
14- 'ticket_count' : sum ([o .tickets_count for o in orders ])
14+ 'ticket_count' : sum ([o .tickets_count for o in orders if o . status == status ])
1515 }
1616
1717
You can’t perform that action at this time.
0 commit comments