Skip to content

Commit

Permalink
reset import status
Browse files Browse the repository at this point in the history
  • Loading branch information
Their Name authored and alphatownsman committed Oct 24, 2023
1 parent 932b13c commit c872af7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions users/management/commands/import_tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from loguru import logger
from tqdm import tqdm

from users.models import Preference, User


class Command(BaseCommand):
help = "Manage import tasks"

def add_arguments(self, parser):
parser.add_argument(
"--reset",
action="store_true",
)

def handle(self, *args, **options):
if options["reset"]:
count = 0
for user in tqdm(User.objects.all()):
if user.preference.import_status.get("douban_pending"):
user.preference.import_status["douban_pending"] = False
user.preference.save(update_fields=["import_status"])
count += 1
self.stdout.write(self.style.SUCCESS(f"{count} users reset"))

0 comments on commit c872af7

Please sign in to comment.