Skip to content

Instantly share code, notes, and snippets.

@h0rn3t
Forked from artemholovnia/8710.py
Last active October 11, 2023 17:42
Show Gist options
  • Save h0rn3t/cbda79bfa3cdafff52c86a5360fbcdda to your computer and use it in GitHub Desktop.
Save h0rn3t/cbda79bfa3cdafff52c86a5360fbcdda to your computer and use it in GitHub Desktop.
SYNC OPENSEARCH
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()[from_:to].values_list("id", flat=True)
now = datetime_utcnow().isoformat()
client.rpush(
"ms_ap_sync_queue",
*[f"es:{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