Skip to content

Commit 1231e23

Browse files
authored
Merge pull request internetarchive#11183 from jimchamp/fix-pref-script-bugs
Fix bugs in preference migration script
2 parents 7f3bd34 + 8beca00 commit 1231e23

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scripts/migrations/write_prefs_to_store.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def copy_preferences_to_store(keys, verbose: bool = False) -> list[str]:
3434
try:
3535
if verbose:
3636
print(f"Writing {key} to store...")
37-
username = key.split('/')[-1]
37+
username = key.split('/')[-2]
3838
ol_acct = OpenLibraryAccount.get_by_username(username)
3939
prefs = (ol_acct and ol_acct.get_user().preferences()) or {}
4040
if ol_acct and prefs.get('type', '') != PREFERENCE_TYPE:
@@ -112,6 +112,7 @@ def main(args):
112112
f"Begin writing batch of {len(affected_pref_keys)} preferences to store..."
113113
)
114114
cur_batch = affected_pref_keys[:1000]
115+
affected_pref_keys = affected_pref_keys[1000:]
115116
retries = copy_preferences_to_store(cur_batch, verbose=args.verbose)
116117
affected_pref_keys.extend(retries)
117118
print(f"Batch completed with {len(retries)} errors\n")

0 commit comments

Comments
 (0)