def debug_biblio_for_live_profiles(args): url_slug = args.get("url_slug", None) min_url_slug = args.get("min_url_slug", None) q = profile_query(url_slug, min_url_slug) from totalimpact.providers.bibtex import Bibtex bibtex_provider = Bibtex() from totalimpactwebapp.product import put_biblio_in_product for profile in windowed_query(q, Profile.url_slug, 25): logger.info(u"in debug_biblio_for_live_profiles for {url_slug}".format( url_slug=profile.url_slug)) for product in profile.products_not_removed: if product.biblio \ and hasattr(product.biblio, "journal") \ and "journal =" in product.biblio.journal \ and hasattr(product.biblio, "full_citation") \ and "journal" in product.biblio.full_citation: print "got one:", product.tiid, product.biblio.full_citation aliases = bibtex_provider.member_items(product.biblio.full_citation) print aliases for alias in aliases: (ns, nid) = alias if ns=="biblio": product = put_biblio_in_product(product, nid, provider_name="bibtex") print product.biblio db.session.merge(product) commit(db) else: pass
def add_to_database_if_nonzero( product, new_content, method_name, provider_name): updated_product = None if new_content and product: if method_name=="aliases": updated_product = put_aliases_in_product(product, new_content) elif method_name=="biblio": updated_product = put_biblio_in_product(product, new_content, provider_name) elif method_name=="metrics": for metric_name in new_content: if new_content[metric_name]: updated_product = put_snap_in_product(product, metric_name, new_content[metric_name]) else: logger.warning(u"ack, supposed to save something i don't know about: " + str(new_content)) if updated_product: updated_product.last_refresh_finished = datetime.datetime.utcnow() db.session.merge(updated_product) commit(db) else: product.last_refresh_finished = datetime.datetime.utcnow() db.session.add(product) commit(db) return