From 53c614d8139eafc1504f34e35691b33c83270579 Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Fri, 22 Aug 2025 16:00:34 -0400 Subject: [PATCH] Almost done with Anthology script for learner properties. --- .../anthology-update-learner-props.py | 56 +++++++++++++++---- Tasks.md | 2 +- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/Scripts/API_Tests/anthology-update-learner-props.py b/Scripts/API_Tests/anthology-update-learner-props.py index dfa5bb3d..68a17435 100644 --- a/Scripts/API_Tests/anthology-update-learner-props.py +++ b/Scripts/API_Tests/anthology-update-learner-props.py @@ -1,4 +1,5 @@ import pprint +import csv import requests import Apikeys @@ -9,9 +10,10 @@ pp=pprint.PrettyPrinter(indent=4) def main(): count = 0 + new_full_list = [] while True: count += 1 - getpplprops = f"{BASEURL}/properties/people" + getpplprops = f"{BASEURL}/properties/people?limit=100&page={count}" # getppl = f"{BASEURL}/people?limit=100&page={count}" getpplreq = requests.get(getpplprops, headers=HEADERS).json() nextlink = getpplreq["links"] @@ -25,21 +27,24 @@ def main(): except AttributeError as e: print(e) subs = subscription_levels - # print(uuid, subs) - print(name["attributes"]["properties"]["email"]) - change_property_values(uuid, subs) + # print(name["attributes"]["properties"]["email"]) + new_subscriptions = change_property_values(uuid, subs) + paired_with_uuid = (uuid, new_subscriptions) + new_full_list.append(paired_with_uuid) print(count) - if "next" not in nextlink or count == 2: + if "next" not in nextlink or count == 5: break + return new_full_list + def change_property_values(uuid, subs): strip_list = [] subs = list(filter(lambda x: x != '', subs)) subs = list(filter(lambda x: x != ' ', subs)) - print("\n") - print(subs) - print(len(subs)) + # print("\n") + # print(subs) + # print(len(subs)) for item in subs: stripped = item.strip() x = "" @@ -54,13 +59,40 @@ def change_property_values(uuid, subs): strip_list.append(x) strip_list = list(filter(lambda x: x != '', strip_list)) strip_list = set(strip_list) - print(strip_list) - print(len(strip_list)) + # print(strip_list) + # print(len(strip_list)) + return strip_list +def chunk_and_push(new_full_list): + fill_props_url = f"{BASEURL}/properties/people/bulk" + if len(new_full_list) > 10: + for chunk in range(0, len(new_full_list), 10): + i = chunk + mediumload = [] + to_push = new_full_list[i:i+10] + for individuals in to_push: + subscripts = individuals[1] + subscripts = str(subscripts).replace('{', '').replace('}','').replace("'",'') + print(subscripts) + miniload = { + "attributes": { "properties": { "subscription_level": subscripts } }, + "id": individuals[0], + "type": "person_properties" + }, + mediumload.append(miniload) + payload = { "data": mediumload } + print(payload) +def backup_current_props(new_full_list): + for pers_props in new_full_list: + with open('/Users/normrasmussen/Downloads/new_props_backup.csv', 'a') as file: + backup = csv.writer(file, delimiter=',') + backup.writerow(pers_props) if __name__ == "__main__": - main() + new_full_list = main() + # backup_current_props(new_full_list) + chunk_and_push(new_full_list) # str1 = "Anthology Encompass: Essential" # str2 = str1.replace("Essential", "Core") # print(str1) @@ -75,4 +107,4 @@ if __name__ == "__main__": Anthology Student: Enhanced Anthology Student: Enhanced+ Anthology National University: Enhanced+ - """ +""" diff --git a/Tasks.md b/Tasks.md index 7cb76410..7b159a85 100644 --- a/Tasks.md +++ b/Tasks.md @@ -70,4 +70,4 @@ ## Workhuman - [X] Submit Publishing Request to product. Currently, WH shares direct-to-activtiy links from their community page to showcase certain features. For instance, one of their links [uses this url](https://community.workhuman.com/education/courses/bada004e-b721-4eed-86b2-9fc58edd3276/activities/eae94898-b7e5-4ce9-a4c9-568e8687d92a). If they add new activities, the users who click that link won't see them because they would need to click "Retake course" which doesn't exist. -- [X] Ask about increasing the Password security policy for Customer Hub (CC+CE). The request from the Workhuman Infosec team is:"The password policy should require a minimum length of at least twelve characters to increase complexity and resistance to brute-force attacks. When two-factor authentication (2FA) is enforced, a minimum length of eight characters may be acceptable. Specific character class requirements, such as mandating uppercase letters, numbers, or symbols, should be avoided in favour of allowing any printable Unicode characters to encourage the use of passphrases." +- [X] Ask about increasing the Password security policy for Customer Hub (CC+CE). The request from the Workhuman Infosec team is:"The password policy should require a minimum length of at least twelve characters to increase complexity and resistance to brute-force attacks. When two-factor authentication (2FA) is enforced, a minimum length of eight characters may be acceptable. Specific character class requirements, such as mandating uppercase letters, numbers, or symbols, should be avoided in favour of allowing any printable Unicode characters to encourage the use of passphrases.