Skip to content

Commit 051d69e

Browse files
prabhupantiamareebjamal
authored andcommitted
Add hooks for admin statistics (#5530)
1 parent a3b646e commit 051d69e

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

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)