def multi_index_node_order(order_keys): logging.info('Indexing %s node orders', len(order_keys)) orders = ndb.get_multi(order_keys) # type: list[NodeOrder] usernames = get_iyo_usernames([order.app_email for order in orders]) return NODE_ORDER_INDEX.put([ create_node_order_document(order, usernames.get(order.app_email)) for order in orders ])
def _set_intercom_tags_node_orders(node_order_keys, dry_run): node_orders = ndb.get_multi(node_order_keys) # type: list[NodeOrder] usernames = get_iyo_usernames([order.app_email for order in node_orders]) tags = defaultdict(list) for order in node_orders: order_tags = get_intercom_tags_for_node_order(order) for tag in order_tags: iyo_username = usernames.get(order.app_email) if iyo_username not in tags[tag]: tags[tag].append(iyo_username) _set_tags(tags, dry_run)
def multi_index_investment_agreement(order_keys): # type: (list[ndb.Key]) -> list[search.PutResult] logging.info('Indexing %s investment agreements', len(order_keys)) orders = ndb.get_multi(order_keys) # type: list[InvestmentAgreement] usernames = get_iyo_usernames([order.app_email for order in orders]) to_put = [ create_investment_agreement_document(order, usernames.get(order.app_email)) for order in orders ] return INVESTMENT_INDEX.put(to_put)
def _set_intercom_tags_investment_agreements(agreement_keys, dry_run): investments = ndb.get_multi(agreement_keys) # type: list[InvestmentAgreement] usernames = get_iyo_usernames([i.app_email for i in investments]) tags = defaultdict(list) for investment in investments: investment_tags = get_intercom_tags_for_investment(investment) if investment_tags: for tag in investment_tags: iyo_username = usernames.get(investment.app_email) if iyo_username not in tags[tag]: tags[tag].append(iyo_username) _set_tags(tags, dry_run)