Skip to content

Instantly share code, notes, and snippets.

@artemholovnia
Last active October 11, 2023 17:37
Show Gist options
  • Save artemholovnia/8cd3b863eb09b8b7d41fd7feaf9b0185 to your computer and use it in GitHub Desktop.
Save artemholovnia/8cd3b863eb09b8b7d41fd7feaf9b0185 to your computer and use it in GitHub Desktop.
8710
python manage.py shell -c '
from django_redis import get_redis_connection
from datahub_core.datetime_utils import datetime_utcnow
from ms_tko.models import AccountingPoint
client = get_redis_connection("default")
counter = 0
chunk_size = 50000
summ_cnt = AccountingPoint.objects.filter().count()
while True:
from_, to = counter * chunk_size, counter * chunk_size + chunk_size
ids = AccountingPoint.objects.all().order_by("-id")[from_:to].values_list("id", flat=True)
now = datetime_utcnow().isoformat()
client.rpush(
"ms_ap:es",
*[f"{id_}:{now}" for id_ in ids],
)
print(f"queued: {from_} - {to}")
if len(ids) < chunk_size:
break
counter += 1
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment