@@ -476,14 +476,22 @@ def update_user_authorities(spreadsheet, ch_client, sheet_records, portal_name):
476476 all_user_map = get_new_user_map (spreadsheet , sheet_records , {}, portal_name )
477477 if all_user_map is None :
478478 return None
479- print ('Updating authorities for each user in current portal user list' , file = OUTPUT_FILE )
479+ total = len (all_user_map )
480+ print ('Updating authorities for %d user(s) in current portal user list' % total , file = OUTPUT_FILE )
480481 new_authority_pairs = []
481- for user in all_user_map .values ():
482+ for i , user in enumerate (all_user_map .values (), 1 ):
483+ print (' [%d/%d] checking authorities for %s' % (i , total , user .google_email ), file = OUTPUT_FILE )
482484 sheet_authorities = set (user .authorities )
483485 db_authorities = set (get_user_authorities (ch_client , user .google_email ))
484- new_authority_pairs += [(user .google_email , authority ) for authority in sheet_authorities - db_authorities ]
486+ added = [(user .google_email , authority ) for authority in sheet_authorities - db_authorities ]
487+ if added :
488+ print (' -> adding %d new authority(s): %s' % (len (added ), [a for _ , a in added ]), file = OUTPUT_FILE )
489+ new_authority_pairs += added
485490 if new_authority_pairs :
491+ print ('Inserting %d new authority pair(s) into ClickHouse' % len (new_authority_pairs ), file = OUTPUT_FILE )
486492 ch_client .insert ('authorities' , new_authority_pairs , column_names = ['email' , 'authority' ])
493+ else :
494+ print ('No new authorities to insert' , file = OUTPUT_FILE )
487495
488496# ------------------------------------------------------------------------------
489497# adds rejected user emails to rejected_users worksheet in an idempotent fashion
0 commit comments