Enhance promo code management and user statistics features
- Introduced a unified promo code management system, allowing admins to view and manage both active and inactive promo codes with detailed information. - Updated the promo code detail view to include status indicators and management options for editing, toggling status, and viewing activation history. - Enhanced user statistics display by restructuring the information layout and adding new labels for clarity. - Improved localization files to support new messages and labels related to promo code management and user statistics. - Implemented error handling for suspicious promo code attempts, integrating a notification system for better admin awareness.
This commit is contained in:
@@ -470,41 +470,23 @@ class PanelApiService:
|
||||
return await panel_sync_dal.get_panel_sync_status(session)
|
||||
|
||||
|
||||
async def get_panel_statistics(self) -> Optional[Dict[str, Any]]:
|
||||
"""Get general panel statistics"""
|
||||
response_data = await self._request("GET", "/admin/stats", log_full_response=False)
|
||||
async def get_system_stats(self) -> Optional[Dict[str, Any]]:
|
||||
"""Get system statistics (CPU, memory, users counts)"""
|
||||
response_data = await self._request("GET", "/system/stats", log_full_response=False)
|
||||
if response_data and not response_data.get("error") and "response" in response_data:
|
||||
return response_data.get("response")
|
||||
return None
|
||||
|
||||
async def get_bandwidth_stats(self) -> Optional[Dict[str, Any]]:
|
||||
"""Get bandwidth statistics"""
|
||||
response_data = await self._request("GET", "/system/stats/bandwidth", log_full_response=False)
|
||||
if response_data and not response_data.get("error") and "response" in response_data:
|
||||
return response_data.get("response")
|
||||
return None
|
||||
|
||||
async def get_nodes_statistics(self) -> Optional[List[Dict[str, Any]]]:
|
||||
async def get_nodes_statistics(self) -> Optional[Dict[str, Any]]:
|
||||
"""Get nodes statistics"""
|
||||
response_data = await self._request("GET", "/admin/nodes/stats", log_full_response=False)
|
||||
if response_data and not response_data.get("error") and "response" in response_data:
|
||||
return response_data.get("response", {}).get("nodes", [])
|
||||
return None
|
||||
|
||||
|
||||
async def get_system_info(self) -> Optional[Dict[str, Any]]:
|
||||
"""Get system information"""
|
||||
response_data = await self._request("GET", "/admin/system/info", log_full_response=False)
|
||||
if response_data and not response_data.get("error") and "response" in response_data:
|
||||
return response_data.get("response")
|
||||
return None
|
||||
|
||||
|
||||
async def get_online_users_count(self) -> Optional[int]:
|
||||
"""Get count of currently online users"""
|
||||
response_data = await self._request("GET", "/admin/stats/online-users", log_full_response=False)
|
||||
if response_data and not response_data.get("error") and "response" in response_data:
|
||||
return response_data.get("response", {}).get("count", 0)
|
||||
return None
|
||||
|
||||
|
||||
async def get_users_activity_stats(self) -> Optional[Dict[str, Any]]:
|
||||
"""Get users activity statistics (today, week, never connected)"""
|
||||
response_data = await self._request("GET", "/admin/stats/users-activity", log_full_response=False)
|
||||
response_data = await self._request("GET", "/system/stats/nodes", log_full_response=False)
|
||||
if response_data and not response_data.get("error") and "response" in response_data:
|
||||
return response_data.get("response")
|
||||
return None
|
||||
@@ -11,7 +11,7 @@ from db.models import PromoCode, User
|
||||
|
||||
from .subscription_service import SubscriptionService
|
||||
from bot.middlewares.i18n import JsonI18n
|
||||
from .notification_service import notify_admin_promo_activation, NotificationService
|
||||
from .notification_service import NotificationService
|
||||
|
||||
|
||||
class PromoCodeService:
|
||||
@@ -75,15 +75,6 @@ class PromoCodeService:
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to send promo activation notification: {e}")
|
||||
|
||||
# Legacy notification for backwards compatibility
|
||||
await notify_admin_promo_activation(
|
||||
self.bot,
|
||||
self.settings,
|
||||
self.i18n,
|
||||
user_id,
|
||||
code_input_upper,
|
||||
bonus_days,
|
||||
)
|
||||
return True, new_end_date
|
||||
else:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user