def getBirthdays(action, operation, id, query): logger.info("hoh-people-api->getBirthdays - Entry") daysBefore = getQueryString(query, "daysBefore", "28") daysAfter = getQueryString(query, "daysAfter", "7") allFlag = getQueryString(query, "allFlag", "false") generations = getQueryString(query, "generations", "3") today = getQueryString(query, "date", "") logger.info("hoh-people-api->getBirthdays - daysBefore = " + daysBefore + ", daysAfter = " + daysAfter + " allFlag =" + allFlag + " generations = " + generations) context = mycontext.getContext() mycontext.setToday(context, today) list = birthdays.getBirthdayList(context, generations, daysBefore, daysAfter, allFlag) # curate the list returned to just what we want retList = [] for val in list: entry = {} entry['id'] = val['id'] entry['daysAway'] = val['daysAway'] entry['name'] = peeps.getPreferredName(val, True) if 'birthCertificateSex' in val: entry['birthSex'] = val['birthCertificateSex'] else: entry['birthSex'] = "unknown" if 'dod' in val: entry['dobFmt'] = FormatMyDate(val, 'dob') entry['dodFmt'] = FormatMyDate(val, 'dod') entry['living'] = "False" entry['name'] += FormatMyFamName( val) # Return full name for the departed else: entry['living'] = "True" if int(val['age']) > 16 and entry['living'] == "True": entry['ageAtBirthday'] = "-1" else: entry['ageAtBirthday'] = val['age'] retList.append(entry) retJson = json.dumps(retList) logger.info("hoh-people-api->getBirthdays - returned item: " + str(retJson) + " bytes") logger.debug("hoh-people-api->getBirthdays - returning:" + retJson) logger.info("hoh-people-api->getBirthdays - Exit") return retJson
def test1_0(): print("Test1_0 - level 0 peeps") context = mycontext.newContext() #context = peeps.loadPeepFile(context, '../hoh-people.json') context = mycontext.setPeepFile(context, '../hoh-people.json') items = peeps.getBirthdayList(context, "0", "365", "365", "True") print("Peeps matched") for item in items: print("peep " + peeps.getPreferredName(item) + " birthday is in " + item['daysAway'] + " days") assert (len(items) >= 0) return
def test1_4(): context = None print("Test1_4 - level * (ALL) peeps") #print("context (before) = " + str(context)) # context = peeps.loadPeepFile(context, '../hoh-people.json') context = mycontext.setPeepFile(context, '../hoh-people.json') #print("context (after) = " + str(context)) items = peeps.getBirthdayList(context, "*", "180", "181", "True") print("Peeps matched") for item in items: print("peep " + peeps.getPreferredName(item) + " birthday is in " + item['daysAway'] + " days") assert (len(items) >= 0) return