feat: Add VLC service for sound playback and management
- Implemented VLCService to handle sound playback using VLC. - Added routes for soundboard management including play, stop, and status. - Introduced admin routes for sound normalization and scanning. - Updated user model and services to accommodate new functionalities. - Enhanced error handling and logging throughout the application. - Updated dependencies to include python-vlc for sound playback capabilities.
This commit is contained in:
@@ -15,13 +15,13 @@ class CreditService:
|
||||
@staticmethod
|
||||
def refill_all_users_credits() -> dict:
|
||||
"""Refill credits for all active users based on their plan.
|
||||
|
||||
|
||||
This function:
|
||||
1. Gets all active users
|
||||
2. For each user, adds their plan's daily credit amount
|
||||
3. Ensures credits never exceed the plan's max_credits limit
|
||||
4. Updates all users in a single database transaction
|
||||
|
||||
|
||||
Returns:
|
||||
dict: Summary of the refill operation
|
||||
|
||||
@@ -44,7 +44,9 @@ class CreditService:
|
||||
|
||||
for user in users:
|
||||
if not user.plan:
|
||||
logger.warning(f"User {user.email} has no plan assigned, skipping")
|
||||
logger.warning(
|
||||
f"User {user.email} has no plan assigned, skipping"
|
||||
)
|
||||
continue
|
||||
|
||||
# Calculate new credit amount, capped at plan max
|
||||
@@ -53,7 +55,9 @@ class CreditService:
|
||||
max_credits = user.plan.max_credits
|
||||
|
||||
# Add daily credits but don't exceed maximum
|
||||
new_credits = min(current_credits + plan_daily_credits, max_credits)
|
||||
new_credits = min(
|
||||
current_credits + plan_daily_credits, max_credits
|
||||
)
|
||||
credits_added = new_credits - current_credits
|
||||
|
||||
if credits_added > 0:
|
||||
@@ -104,10 +108,10 @@ class CreditService:
|
||||
@staticmethod
|
||||
def get_user_credit_info(user_id: int) -> dict:
|
||||
"""Get detailed credit information for a specific user.
|
||||
|
||||
|
||||
Args:
|
||||
user_id: The user's ID
|
||||
|
||||
|
||||
Returns:
|
||||
dict: User's credit information
|
||||
|
||||
|
||||
Reference in New Issue
Block a user