diff --git a/app/api/services/office_dashboard.py b/app/api/services/office_dashboard.py index ab32ad6..271d9a9 100644 --- a/app/api/services/office_dashboard.py +++ b/app/api/services/office_dashboard.py @@ -88,13 +88,15 @@ class OfficeDashboardService(BaseService): 'updated': t.updated } for t in subscription] + sub_count = MembersProducts.get_subscription_counts(0) + dashboard_data = { "subscription": subscription_data, "loans": { "currency": "Naira", "currency_text": "\u20a6", "text": "this week", - "value": 159999.0 + "value": sub_count }, "payments": { "currency": "Dollars", diff --git a/app/models/members_products.py b/app/models/members_products.py index 109effd..b6bbf58 100644 --- a/app/models/members_products.py +++ b/app/models/members_products.py @@ -46,6 +46,15 @@ class MembersProducts(db.Model): back_populates="members_products", ) + @classmethod + def get_subscription_counts(cls, member_id): + subscription_count = cls.query.filter_by( + status=7 + ).count() + if not subscription_count: + return 0 + return subscription_count + @classmethod def get_member_productlist_by_member_id(cls, member_id): member_products = cls.query.filter_by(member_id=str(member_id))