Skip to content

Commit

Permalink
add command to update asset slug in assignments telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavomm19 committed Jan 14, 2025
1 parent 41a243a commit c24df7e
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.core.management.base import BaseCommand
from breathecode.assignments.models import AssignmentTelemetry
from breathecode.registry.models import Asset


class Command(BaseCommand):
help = "Update assets slugs in assignments telemetry"

def handle(self, *args, **options):
try:
telemetries = AssignmentTelemetry.objects.all()
for assignment_telemetry in telemetries:
asset_slug = assignment_telemetry.asset_slug
asset = Asset.get_by_slug(asset_slug)
if asset is not None and asset.slug != asset_slug:
assignment_telemetry.asset_slug = asset.slug
assignment_telemetry.save()
except Exception:
self.stderr.write("Failed to update telemetry assets slugs")

0 comments on commit c24df7e

Please sign in to comment.