-
-
Save h0rn3t/cbda79bfa3cdafff52c86a5360fbcdda to your computer and use it in GitHub Desktop.
SYNC OPENSEARCH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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