Created
May 1, 2023 14:41
-
-
Save CyberRex0/af2676ef9ac42444bd9d3b97b4178619 to your computer and use it in GitHub Desktop.
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
import orjson | |
import requests | |
import math | |
print('Loading notes...', end='') | |
with open('notes.json') as f: | |
notes = orjson.loads(f.read()) | |
print('Done') | |
bpercent = 0 | |
percent = 0 | |
noteslen = len(notes) | |
i = 0 | |
step = 1000 | |
while True: | |
if i >= noteslen: | |
break | |
if bpercent != percent: | |
bpercent = percent | |
print(f'Adding to index... {percent}%') | |
r = requests.post('http://localhost:7700/indexes/misskey/documents?primaryKey=id', json=notes[i:i+step]) | |
if r.status_code != 202: | |
print(f'Error ({r.status_code})') | |
continue | |
i = i + step | |
percent = math.floor(i / noteslen * 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment