Skip to content

Commit

Permalink
Merge pull request #1539 from gustavomm19/context-command
Browse files Browse the repository at this point in the history
add flag --all to generate_asset_context command
  • Loading branch information
tommygonzaleza authored Jan 27, 2025
2 parents c125315 + 45ebeb2 commit 5ede2e8
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@
class Command(BaseCommand):
help = "Generate asset context for all assets."

def add_arguments(self, parser):
parser.add_argument("--all", type=str, help="Allow to update or create context on all assets")

def handle(self, *args, **options):
assets = Asset.objects.filter(assetcontext__isnull=True)

filters = {}
assets = Asset.objects.all()
if "all" not in options or options["all"] not in ["true", "True", "1"]:
filters["assetcontext__isnull"] = True
assets = assets.filter(**filters)

for asset in assets:
try:
AssetContext.objects.update_or_create(asset=asset, defaults={"status": "PROCESSING"})
Expand Down

0 comments on commit 5ede2e8

Please sign in to comment.