multi sector clustering erroro rasing, adn tasks page word coutn monthly limits removal

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-19 08:20:43 +00:00
parent e57c4bf1ac
commit 29ce8139d9
8 changed files with 155 additions and 86 deletions

View File

@@ -358,31 +358,8 @@ class Content(SoftDeletableModel, SiteSectorBaseModel):
super().save(*args, **kwargs)
# Increment usage for new content or if word count increased
if self.content_html and self.word_count:
# Only count newly generated words
new_words = self.word_count - old_word_count if not is_new else self.word_count
if new_words > 0:
from igny8_core.business.billing.services.limit_service import LimitService
try:
# Get account from site
account = self.site.account if self.site else None
if account:
LimitService.increment_usage(
account=account,
limit_type='content_words',
amount=new_words,
metadata={
'content_id': self.id,
'content_title': self.title,
'site_id': self.site.id if self.site else None,
}
)
except Exception as e:
import logging
logger = logging.getLogger(__name__)
logger.error(f"Error incrementing word usage for content {self.id}: {str(e)}")
# NOTE: Content words no longer tracked as a monthly plan limit.
# Credits are the only enforcement for content generation.
def soft_delete(self, user=None, reason=None, retention_days=None):
"""

View File

@@ -30,20 +30,12 @@ class ContentGenerationService:
Raises:
InsufficientCreditsError: If account doesn't have enough credits
"""
from igny8_core.business.billing.services.limit_service import LimitService, MonthlyLimitExceededError
# Get tasks
tasks = Tasks.objects.filter(id__in=task_ids, account=account)
# Calculate estimated credits needed based on word count
total_word_count = sum(task.word_count or 1000 for task in tasks)
# Check monthly word count limit
try:
LimitService.check_monthly_limit(account, 'content_words', amount=total_word_count)
except MonthlyLimitExceededError as e:
raise InsufficientCreditsError(str(e))
# Check credits
try:
self.credit_service.check_credits(account, 'content_generation', total_word_count)