def get_transactions(link): # tuple of (transaction_id, key) trans_tuples = [(v[CAMPAIGN.trans_id], k) for k, v in getattr(link, "campaigns", {}).iteritems() if v[CAMPAIGN.trans_id] != 0] bids = authorize.get_transactions(*trans_tuples) return dict((indx, bids.get((t, indx))) for t, indx in trans_tuples)
def get_transactions(link): """ Gets records from the bids table for all campaigns on link that have a non-zero transaction id. Note this set includes auth, charged, and void transactions, any of which could be freebies and/or finished running. Returns a dict mapping campaign ids to Bid objects. """ campaigns = PromoCampaign._query(PromoCampaign.c.link_id == link._id, PromoCampaign.c.trans_id != 0, data=True) trans_tuples = [(camp.trans_id, camp._id) for camp in campaigns] bids = authorize.get_transactions(*trans_tuples) bids_by_campaign = {} for trans_id, campaign_id in trans_tuples: bids_by_campaign[campaign_id] = bids.get((trans_id, campaign_id)) return bids_by_campaign
def get_transactions(link): ''' Gets records from the bids table for all campaigns on link that have a non-zero transaction id. Note this set includes auth, charged, and void transactions, any of which could be freebies and/or finished running. Returns a dict mapping campaign ids to Bid objects. ''' campaigns = PromoCampaign._query(PromoCampaign.c.link_id == link._id, PromoCampaign.c.trans_id != 0, data=True) trans_tuples = [(camp.trans_id, camp._id) for camp in campaigns] bids = authorize.get_transactions(*trans_tuples) bids_by_campaign = {} for trans_id, campaign_id in trans_tuples: bids_by_campaign[campaign_id] = bids.get((trans_id, campaign_id)) return bids_by_campaign