def process_update_record(load_config, update_record_name): logger = log_utils.create_logger('pubmed2018_update', load_config.log_files_directory()) logger.info('Loading update record: ' + str(update_record_name)) update_records_directory = get_update_records_directory(load_config) update_record = file_utils.load_file(update_records_directory, update_record_name) local_date = update_record['local_date'] update_data = update_record['update_data'] docs_with_new_citations = update_record['docs_with_new_citations'] logger.info('Update record loaded') logger.info('Date: ' + str(local_date)) logger.info('Update files: ') for update_file in update_data: logger.info(update_file) logger.info('Docs with new citations: ' + str(len(docs_with_new_citations))) all_prospects = send_prospective_citations_notifications(logger, docs_with_new_citations) # Send update notification logger.info('Sending update status mail...') EmailClient.send_update_notifications(local_date, update_data, all_prospects) logger.info('Done')
def process_update_files(is_auto_update, load_config, new_update_files): now = datetime.datetime.now() local_date = now.strftime("%m-%d-%Y") logger = log_utils.create_logger('pubmed2018_update', load_config.log_files_directory()) logger.info(str(len(new_update_files)) + ' update files to process') if len(new_update_files) > 0: logger.info(str(new_update_files)) # Send update start notification if is_auto_update: EmailClient.send_update_start_notification(local_date, new_update_files) # Process files not processed yet # Update processed files list pubmed_updater = PubmedUpdater(logger, new_update_files) pubmed_updater.run() # Send prospective cites notifications docs_with_new_citations = pubmed_updater.get_docs_with_new_citations() # Get the update summary logger.info('Generating update summary...') update_data = generate_update_summary(pubmed_updater, new_update_files) logger.info('Saving update summary...') save_update_record_for_date(load_config, local_date, update_data, docs_with_new_citations) all_prospects = send_prospective_citations_notifications(logger, docs_with_new_citations) # # Send update notification logger.info('Sending update status mail...') EmailClient.send_update_notifications(local_date, update_data, all_prospects) # Save existing pmids to file logger.info('Saving new pmids...') pubmed_updater.save_new_pmids() # Update processed files list update_processed_update_files(new_update_files) else: if is_auto_update: # Send update notification logger.info('Sending update status mail...') EmailClient.send_update_notifications(local_date, [], [])