Skip to content

Commit 3867a69

Browse files
authored
Merge branch 'development' into custom-placeholder-seed-data
2 parents 2ff0317 + 051d69e commit 3867a69

File tree

5 files changed

+93
-4
lines changed

5 files changed

+93
-4
lines changed

app/api/admin_sales/events.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from marshmallow_jsonapi.flask import Schema
33
from flask_rest_jsonapi import ResourceList
44

5+
from app.api.helpers.utilities import dasherize
56
from app.api.bootstrap import api
67
from app.models import db
78
from 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()

app/api/admin_sales/locations.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from marshmallow_jsonapi.flask import Schema
33
from flask_rest_jsonapi import ResourceList
44
from sqlalchemy import func
5+
from app.api.helpers.utilities import dasherize
56

67
from app.api.bootstrap import api
78
from 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')

app/api/admin_sales/organizer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from marshmallow_jsonapi.flask import Schema
33
from flask_rest_jsonapi import ResourceList
44

5+
from app.api.helpers.utilities import dasherize
56
from app.api.bootstrap import api
67
from app.models import db
78
from 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()

app/api/admin_sales/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

tests/hook_main.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4387,3 +4387,83 @@ def favourite_event_delete(transaction):
43874387
user_fav_event = UserFavouriteEventFactory()
43884388
db.session.add(user_fav_event)
43894389
db.session.commit()
4390+
4391+
4392+
# ------------------------- Admin Statistics -------------------------
4393+
4394+
@hooks.before("Admin Statistics > Event Statistics Details > Show Event Statistics")
4395+
def event_statistics_get(transaction):
4396+
"""
4397+
GET /admin/statistics/events
4398+
:param transaction:
4399+
:return:
4400+
"""
4401+
with stash['app'].app_context():
4402+
event = EventFactoryBasic()
4403+
db.session.add(event)
4404+
db.session.commit()
4405+
4406+
4407+
@hooks.before("Admin Statistics > Event Types Statistics Details > Show Event Types Statistics")
4408+
def event_type_statistics_get(transaction):
4409+
"""
4410+
GET /admin/statistics/event-types
4411+
:param transaction:
4412+
:return:
4413+
"""
4414+
with stash['app'].app_context():
4415+
event_type = EventTypeFactory()
4416+
db.session.add(event_type)
4417+
db.session.commit()
4418+
4419+
4420+
@hooks.before("Admin Statistics > Event Topics Statistics Details > Show Event Topics Statistics")
4421+
def event_topic_statistics_get(transaction):
4422+
"""
4423+
GET /admin/statistics/event-topics
4424+
:param transaction:
4425+
:return:
4426+
"""
4427+
with stash['app'].app_context():
4428+
event_topic = EventTopicFactory()
4429+
db.session.add(event_topic)
4430+
db.session.commit()
4431+
4432+
4433+
@hooks.before("Admin Statistics > User Statistics Details > Show User Statistics")
4434+
def user_statistics_get(transaction):
4435+
"""
4436+
GET /admin/statistics/users
4437+
:param transaction:
4438+
:return:
4439+
"""
4440+
with stash['app'].app_context():
4441+
user = UserFactory()
4442+
db.session.add(user)
4443+
db.session.commit()
4444+
4445+
4446+
@hooks.before("Admin Statistics > Session Statistics Details > Show Session Statistics")
4447+
def session_statistics_get(transaction):
4448+
"""
4449+
GET /admin/statistics/sessions
4450+
:param transaction:
4451+
:return:
4452+
"""
4453+
with stash['app'].app_context():
4454+
session = SessionFactory()
4455+
db.session.add(session)
4456+
db.session.commit()
4457+
4458+
4459+
@hooks.before("Admin Statistics > Mail Statistics Details > Show Mail Statistics")
4460+
def mail_statistics_get(transaction):
4461+
"""
4462+
GET /admin/statistics/mails
4463+
:param transaction:
4464+
:return:
4465+
"""
4466+
with stash['app'].app_context():
4467+
mail = MailFactory()
4468+
db.session.add(mail)
4469+
db.session.commit()

0 commit comments

Comments
 (0)