def run_work_finder(i): t0 = time() d = i['data'] print('timestamp:', i['timestamp']) print('author:', d['author']) print('%d records updated:' % len(d['result'])) if 'changeset' not in d: print('no changeset in author merge') print() return changeset = d['changeset'] try: assert len(changeset['data']) == 2 and 'master' in changeset[ 'data'] and 'duplicates' in changeset['data'] except: print(d['changeset']) raise akey = changeset['data']['master'] dup_keys = changeset['data']['duplicates'] #print d['changeset'] print('dups:', dup_keys) title_redirects = find_title_redirects(akey) works = find_works(get_books(akey, books_query(akey)), existing=title_redirects) print('author:', akey) print('works:', works) updated = update_works(akey, works, do_updates=True) print('%d records updated' % len(updated)) t1 = time() - t0 update_times.append(t1) print('update takes: %d seconds' % t1) print()
def run_work_finder(i): t0 = time() d = i['data'] print 'timestamp:', i['timestamp'] print 'author:', d['author'] print '%d records updated:' % len(d['result']) if 'changeset' not in d: print 'no changeset in author merge' print return changeset = d['changeset'] try: assert len(changeset['data']) == 2 and 'master' in changeset['data'] and 'duplicates' in changeset['data'] except: print d['changeset'] raise akey = changeset['data']['master'] dup_keys = changeset['data']['duplicates'] print d['changeset'] print 'dups:', dup_keys title_redirects = find_title_redirects(akey) works = find_works(akey, get_books(akey, books_query(akey)), existing=title_redirects) print 'author:', akey print 'works:', works updated = update_works(akey, works, do_updates=True) print '%d records updated' % len(updated) t1 = time() - t0 update_times.append(t1) print 'update takes: %d seconds' % t1 print
def run_work_finder(i): t0 = time() d = i["data"] print "timestamp:", i["timestamp"] print "author:", d["author"] print "%d records updated:" % len(d["result"]) if "changeset" not in d: print "no changeset in author merge" print return changeset = d["changeset"] try: assert len(changeset["data"]) == 2 and "master" in changeset["data"] and "duplicates" in changeset["data"] except: print d["changeset"] raise akey = changeset["data"]["master"] dup_keys = changeset["data"]["duplicates"] # print d['changeset'] print "dups:", dup_keys title_redirects = find_title_redirects(akey) works = find_works(get_books(akey, books_query(akey)), existing=title_redirects) print "author:", akey print "works:", works updated = update_works(akey, works, do_updates=True) print "%d records updated" % len(updated) t1 = time() - t0 update_times.append(t1) print "update takes: %d seconds" % t1 print
#!/usr/bin/python from __future__ import print_function from openlibrary.catalog.works.find_works import find_title_redirects, find_works, get_books, books_query, update_works import sys from pprint import pprint akey = sys.argv[1] title_redirects = find_title_redirects(akey) print('title_redirects:') pprint(title_redirects) print() works = find_works(akey, get_books(akey, books_query(akey)), existing=title_redirects) works = list(works) print('works:') pprint(works) print() updated = update_works(akey, works, do_updates=True) print('updated works:') pprint(updated)