Some completed tasks. Script for large Walmart enrollment (which brought down the app... oops).
This commit is contained in:
@ -30,7 +30,12 @@
|
|||||||
{% include "featured_courses" %}
|
{% include "featured_courses" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="homepage-widget-container" style="display: flex; flex-wrap: nowrap;">
|
<div class="homepage-widget-container" style="display: flex; flex-wrap: nowrap;">
|
||||||
{% include "widget_badges" %}
|
{% for course in courses.enrolled %}
|
||||||
|
{% if course.id == 'ef6af62f-897e-4eb2-8f0f-47b3df3bc06b' and course.progress == 100 %}
|
||||||
|
{% include "widget_badges" %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% include "widget_course_progress" %}
|
{% include "widget_course_progress" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,23 @@
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import pandas as pd
|
||||||
import pprint
|
import pprint
|
||||||
import csv
|
|
||||||
import Apikeys
|
import Apikeys
|
||||||
|
|
||||||
|
# ************************
|
||||||
|
# IF YOU RUN THIS SCRIPT AGAIN WITH HUNDREDS OF THOUSANDS OF ENROLLMENTS
|
||||||
|
# SPREAD IT OUT OVER MANY BATCHES, IDEALLY ALL DAY
|
||||||
|
# ************************
|
||||||
|
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
APIKEY = Apikeys.CHUBB
|
IMPORTFILE = "~/Downloads/walmart-supplier-mass-grouping.csv"
|
||||||
|
APIKEY = Apikeys.SUPPLIERPROD
|
||||||
HEADERS = {
|
HEADERS = {
|
||||||
"accept": "application/json",
|
"accept": "application/json",
|
||||||
"X-Api-Key": APIKEY,
|
"X-Api-Key": APIKEY,
|
||||||
}
|
}
|
||||||
BASEURL = "https://api.northpass.com/v2/"
|
BASEURL = "https://api2.northpass.com/v2/"
|
||||||
|
|
||||||
def bulk_invite_ppl():
|
def bulk_invite_ppl_under_1500():
|
||||||
"""
|
"""
|
||||||
Bulk endpoint which invites new people and adds them to a group via this structure:
|
Bulk endpoint which invites new people and adds them to a group via this structure:
|
||||||
{
|
{
|
||||||
@ -35,6 +40,43 @@ def bulk_invite_ppl():
|
|||||||
response = requests.post(url, headers=HEADERS, json=payload)
|
response = requests.post(url, headers=HEADERS, json=payload)
|
||||||
print(f"Completed. Status code is {response.status_code}")
|
print(f"Completed. Status code is {response.status_code}")
|
||||||
|
|
||||||
|
def bulk_invite_ppl_over_1500():
|
||||||
|
data = pd.read_csv(IMPORTFILE, encoding = "utf-8")
|
||||||
|
emails = list(data["EmailID"].unique())
|
||||||
|
url = f"{BASEURL}bulk/people"
|
||||||
|
count = 0
|
||||||
|
if len(emails) > 499:
|
||||||
|
for chunk in range(0, len(emails), 499):
|
||||||
|
i = chunk
|
||||||
|
payload_1 = []
|
||||||
|
i_to_add = emails[i: i + 499]
|
||||||
|
for person in i_to_add:
|
||||||
|
miniload = {"email": person, "groups": "Active Suppliers" }
|
||||||
|
miniload1 = {"email": person, "groups": "All Users" }
|
||||||
|
miniload2 = {"email": person, "groups": "Grow With Walmart" }
|
||||||
|
payload_1.append(miniload)
|
||||||
|
payload_1.append(miniload2)
|
||||||
|
payload_1.append(miniload1)
|
||||||
|
print(f"The long length payload has {len(payload_1)} people emails")
|
||||||
|
payload = {"data": {"attributes": {"people": payload_1}}}
|
||||||
|
response = requests.post(url, headers=HEADERS, json=payload)
|
||||||
|
count += 1
|
||||||
|
print(f"Iteration number {count} out of {int(len(emails))/1500}")
|
||||||
|
print(f"Completed. Status code is {response.status_code}")
|
||||||
|
else:
|
||||||
|
payload_1 = []
|
||||||
|
for person in emails:
|
||||||
|
miniload = {"email": person, "groups": "Active Suppliers" }
|
||||||
|
miniload1 = {"email": person, "groups": "All Users" }
|
||||||
|
miniload2 = {"email": person, "groups": "Grow With Walmart" }
|
||||||
|
payload_1.append(miniload)
|
||||||
|
payload_1.append(miniload2)
|
||||||
|
payload_1.append(miniload1)
|
||||||
|
print(f"The payload has {len(payload_1)}")
|
||||||
|
payload = {"data": {"attributes": {"people": payload_1}}}
|
||||||
|
response = requests.post(url, headers=HEADERS, json=payload)
|
||||||
|
print(f"Completed. Status code is {response.status_code}")
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
bulk_invite_ppl()
|
bulk_invite_ppl_over_1500()
|
||||||
|
|||||||
@ -13,27 +13,33 @@ HEADERS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def get_people():
|
def get_people():
|
||||||
count = 0
|
count = 1
|
||||||
while True:
|
while True:
|
||||||
ppl_uuids = []
|
ppl_uuids = []
|
||||||
url = f"{BASEURL}/people?page={count}&limit=100"
|
url = f"{BASEURL}/people?page={count}&limit=100"
|
||||||
print(url)
|
print(url)
|
||||||
count += 1
|
count += 1
|
||||||
response = requests.get(url, headers=HEADERS).json()
|
response = requests.get(url, headers=HEADERS).json()
|
||||||
|
nextlink = response["links"]
|
||||||
for data in response['data']:
|
for data in response['data']:
|
||||||
person_uuid = data['id']
|
person_uuid = data['id']
|
||||||
|
if person_uuid == "c09c6319-7569-46ac-94d5-3885d9de4c2f" or person_uuid == "477de2a1-15cc-4d67-9e95-7e3910dca5d3":
|
||||||
|
print("Found Claudia or Fabian")
|
||||||
|
print(person_uuid)
|
||||||
|
print(data['attributes']['full_name'])
|
||||||
ppl_uuids.append(person_uuid)
|
ppl_uuids.append(person_uuid)
|
||||||
if len(ppl_uuids) == 10:
|
if len(ppl_uuids) == 100:
|
||||||
print(len(ppl_uuids))
|
|
||||||
apply_prop(ppl_uuids)
|
apply_prop(ppl_uuids)
|
||||||
# break
|
# break
|
||||||
|
|
||||||
|
if "next" not in nextlink:
|
||||||
|
break
|
||||||
|
|
||||||
def apply_prop(ppl_uuids):
|
def apply_prop(ppl_uuids):
|
||||||
inserted_load = []
|
inserted_load = []
|
||||||
for person in ppl_uuids:
|
for person in ppl_uuids:
|
||||||
print(person)
|
|
||||||
miniload = {
|
miniload = {
|
||||||
"attributes": { "properties": { "new_content": "true" } },
|
"attributes": { "properties": { "new_content": "True" } },
|
||||||
"id": person,
|
"id": person,
|
||||||
"type": "person_properties"
|
"type": "person_properties"
|
||||||
}
|
}
|
||||||
@ -41,7 +47,16 @@ def apply_prop(ppl_uuids):
|
|||||||
prop_url = f"{BASEURL}/properties/people/bulk"
|
prop_url = f"{BASEURL}/properties/people/bulk"
|
||||||
payload = { "data": inserted_load }
|
payload = { "data": inserted_load }
|
||||||
print(payload)
|
print(payload)
|
||||||
# apply_payload = requests.posts(prop_url, json=payload, headers=HEADERS)
|
apply_payload = requests.post(prop_url, json=payload, headers=HEADERS)
|
||||||
|
stat = apply_payload.status_code
|
||||||
|
print(stat)
|
||||||
|
if "4" in str(stat):
|
||||||
|
print("....!")
|
||||||
|
print("Error! Error!")
|
||||||
|
print(stat.text)
|
||||||
|
print(payload)
|
||||||
|
print("....!")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
get_people()
|
get_people()
|
||||||
|
|||||||
6
Tasks.md
6
Tasks.md
@ -29,14 +29,14 @@
|
|||||||
- [ ] Follow up with Phillip re: the group deletion question - 04-23-2025
|
- [ ] Follow up with Phillip re: the group deletion question - 04-23-2025
|
||||||
- [ ] Upload font files to S3 and make appropriate changes in templates/custom css - 04-23-2025
|
- [ ] Upload font files to S3 and make appropriate changes in templates/custom css - 04-23-2025
|
||||||
- [ ] Move Production templates to Sandbox - 04-23-2025
|
- [ ] Move Production templates to Sandbox - 04-23-2025
|
||||||
- [ ] Add all users in CSV to "Active Supplier", "All Users", and "Grow with Walmart" groups. Set Locale-Person to USA.
|
- [X] Add all users in CSV to "Active Supplier", "All Users", and "Grow with Walmart" groups. Set Locale-Person to USA.
|
||||||
|
|
||||||
## Walmart Volt
|
## Walmart Volt
|
||||||
- [ ] Start compiling ticket list and notes to send to Dan Kardell. - 04-23-2025
|
- [ ] Start compiling ticket list and notes to send to Dan Kardell. - 04-23-2025
|
||||||
|
|
||||||
## Williams-Sonoma
|
## Williams-Sonoma
|
||||||
- [ ] Revert auto-adding of badges to post-new hire dash. Badges should only show when course `97d78ff7-e82b-4f1d-b142-d5ad51fba433` is completed. - 04-15-2025
|
- [ ] Revert auto-adding of badges to post-new hire dash. Badges should only show when course `ef6af62f-897e-4eb2-8f0f-47b3df3bc06b` is completed. - 04-15-2025
|
||||||
|
|
||||||
## Chubb
|
## Chubb
|
||||||
- [ ] Book EMC time for Alisha, Jared, me, Kim, and Jenelle
|
- [X] Book EMC time for Alisha, Jared, me, Kim, and Jenelle
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user