예제 #1
0
 def run(self):
     # get all the IDs of people in the pedigree
     api = API(self.access_token)
     data = api.get_pedigree(self.api_id)
     self.personIDs = []
     for person in data["persons"]:
         self.personIDs.append(person["id"])
예제 #2
0
 def run(self):
     # get all the IDs of people in the pedigree
     api = API(self.access_token)
     data = api.get_pedigree(self.api_id)
     self.personIDs = []
     for person in data['persons']:
         self.personIDs.append(person['id'])
예제 #3
0
    def pedigree(user=None, api_id='', generations=4, sync=False):
        if not sync:
            # check cached IDs and people
            people = Person.get_pedigree(user=user, api_id=api_id)
            if people != []:
                return people

        # get all the IDs of people in the pedigree
        api = API(session['access_token'])
        data = api.get_pedigree(api_id)
        personIDs = []
        for person in data['persons']:
            personIDs.append(person['id'])

        # get all the people in the pedigree
        people = Person.get_people(user=user, personIDs=personIDs, sync=sync)

        # find the leaves and get another four generations for each one
        pdict = {}
        for person in people:
            pdict[person.getID()] = person
        appIDs = Person.find_fourth(api_id=api_id, pdict=pdict)
        appPersonIDs = Person.get_pedigrees(user=user, appIDs=appIDs)
        # remove the people we already fetched
        for personID in personIDs:
            if personID in appPersonIDs:
                appPersonIDs.remove(personID)

        # get all those people
        app_people = Person.get_people(user=user,
                                       personIDs=appPersonIDs,
                                       sync=sync)

        # add them all up
        people.extend(app_people)

        # save people into person
        person = Person.get(user=user, api_id=api_id)
        person.pedigree = []
        for p in people:
            person.pedigree.append(p.api_id)
        person.save()
        return people
예제 #4
0
    def pedigree(user=None, api_id="", generations=4, sync=False):
        if not sync:
            # check cached IDs and people
            people = Person.get_pedigree(user=user, api_id=api_id)
            if people != []:
                return people

        # get all the IDs of people in the pedigree
        api = API(session["access_token"])
        data = api.get_pedigree(api_id)
        personIDs = []
        for person in data["persons"]:
            personIDs.append(person["id"])

        # get all the people in the pedigree
        people = Person.get_people(user=user, personIDs=personIDs, sync=sync)

        # find the leaves and get another four generations for each one
        pdict = {}
        for person in people:
            pdict[person.getID()] = person
        appIDs = Person.find_fourth(api_id=api_id, pdict=pdict)
        appPersonIDs = Person.get_pedigrees(user=user, appIDs=appIDs)
        # remove the people we already fetched
        for personID in personIDs:
            if personID in appPersonIDs:
                appPersonIDs.remove(personID)

        # get all those people
        app_people = Person.get_people(user=user, personIDs=appPersonIDs, sync=sync)

        # add them all up
        people.extend(app_people)

        # save people into person
        person = Person.get(user=user, api_id=api_id)
        person.pedigree = []
        for p in people:
            person.pedigree.append(p.api_id)
        person.save()
        return people