def challenge(self, alter, min_gift=-1.0, max_gift=-1.0, *filt_names): remain_names = [x for x in self.names if x not in filt_names] remain_d = [] new_d = [] if min_gift == -1.0: min_gift = min([min(g) for g in self.histories]) - .01 if max_gift == -1.0: max_gift = max([max(g) for g in self.histories]) + .01 with self._client as client: donors = client.get_database()['donors'] donor_data = donors.find() for d in donor_data: if d['name'] in filt_names: chal_d = Donor('*'+d['name'], d['gifts']) new_d.append(chal_d.challenge(alter, min_gift, max_gift)) else: remain_d.append(Donor(d['name'], d['gifts'])) return Donor_Dict(*(new_d+remain_d))
def challenge(self, alter, min_gift=-1.0, max_gift=-1.0, *filt_names): remain_names = [x for x in self.names if x not in filt_names] remain_d = [] new_d = [] if min_gift == -1.0: min_gift = min([min(g) for g in self.histories]) - .01 if max_gift == -1.0: max_gift = max([max(g) for g in self.histories]) + .01 with self._driver.session() as session: data_cyph = ("MATCH (d:Donor) RETURN d.name as name, d.gifts as gifts") donor_data = session.run(data_cyph) for d in donor_data: if d['name'] in filt_names: chal_d = Donor('*'+d['name'], d['gifts']) new_d.append(chal_d.challenge(alter, min_gift, max_gift)) else: remain_d.append(Donor(d['name'], d['gifts'])) return Donor_Dict(*(new_d+remain_d))