Skip to content

Commit

Permalink
feat: [ACI-931] make discover penalties collect only active
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii committed Apr 16, 2024
1 parent 310d341 commit e73a91f
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions credentials/apps/badges/processing/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,14 @@
import logging
from typing import List

from openedx_events.learning.data import (
BadgeData,
BadgeTemplateData,
CoursePassingStatusData,
UserData,
UserPersonalData,
)

from credentials.apps.badges.models import BadgePenalty, CredlyBadgeTemplate, UserCredential
from credentials.apps.badges.signals.signals import BADGE_PROGRESS_INCOMPLETE
from credentials.apps.badges.utils import keypath
from credentials.apps.badges.models import BadgePenalty


logger = logging.getLogger(__name__)


def discover_penalties(event_type: str) -> List[BadgePenalty]:
return BadgePenalty.objects.filter(event_type=event_type)
return BadgePenalty.objects.filter(event_type=event_type, template__is_active=True)


def process_penalties(event_type, username, payload_dict):
Expand All @@ -46,7 +36,5 @@ def process_penalties(event_type, username, payload_dict):
logger.debug("BADGES: found %s penalties to process.", len(penalties))

for penalty in penalties:
if not penalty.is_active:
continue
if penalty.apply_rules(payload_dict):
penalty.reset_requirements(username)

0 comments on commit e73a91f

Please sign in to comment.