This is a little bit technical but I'll try to break it down into the simplest steps I can, also it shouldn't take much more than 5-10 minutes to complete all these steps.
First open up an online python interpreter like this one
Then on the left hand side of the screen paste the python code from here
import jsonimport requests#javascritp to get unit# window.location.href.substring(window.location.href.lastIndexOf('/')+1)unit=''#javascirpt to get directory_access_token# document.cookie.match(new RegExp('(^| )directory_access_token=([^;]+)'))[2]directoryAccessToken=''#javascript to get directory_identity_token# document.cookie.match(new RegExp('(^| )directory_identity_token=([^;]+)'))[2]directoryIdentityToken=''#have to get bearer from developer toolsbearer=''def parseWardData(jsonData):membersInWard = 0membersWithCalling = 0membersWithoutCalling = 0membersWithMultipleCallings = 0membersWithStakeCallings = 0visibleChildrenRecordsInWard = 0#loop over each householdfor houseHold in jsonData:#loop over each member, count each memberif "members" in houseHold and isinstance(houseHold["members"], list) and len(houseHold["members"]) > 0:for member in houseHold["members"]:countThePositionForThisMember = Trueif member["head"] == True:membersInWard = membersInWard + 1if "positions" in member and isinstance(member["positions"], list) and len(member["positions"]) > 0:if len(member["positions"]) > 1:membersWithMultipleCallings = membersWithMultipleCallings + 1for position in member["positions"]:if countThePositionForThisMember:membersWithCalling = membersWithCalling + 1countThePositionForThisMember = Falseif position["unitNumber"] != member["unitNumber"]:membersWithStakeCallings = membersWithStakeCallings + 1else:membersWithoutCalling = membersWithoutCalling + 1else:visibleChildrenRecordsInWard = visibleChildrenRecordsInWard + 1print("Adult members in ward: " + str(membersInWard))print("Adult members with callings: " + str(membersWithCalling))print("Adult members without a calling: " + str(membersWithoutCalling))print("Adult members with multiple callings: " + str(membersWithMultipleCallings))print("Adult members in the ward with Stake callings: " + str(membersWithStakeCallings))print("Average estimated adult activity in ward: " + str(membersWithCalling / membersInWard))return membersInWard, membersWithCallingmembersInStake = 0membersInStakeWithCalling = 0cookies = {'directory_access_token':directoryAccessToken+';', 'directory_identity_token':directoryIdentityToken+';'}headers = {'authorization': 'Bearer ' + bearer}r = requests.get('https://directory.churchofjesuschrist.org/api/v4/units/'+unit, headers=headers, cookies=cookies)stakeData = json.loads(r.text)#print("stake: " + str(stakeData))if 'childUnits' in stakeData:childUnits = stakeData['childUnits']#print("childUnits: " + str(childUnits))for childUnit in childUnits:#print("childUnit: " + str(childUnit))unitNumber = childUnit['unitNumber']r = requests.get('https://directory.churchofjesuschrist.org/api/v4/households?unit='+str(unitNumber), headers=headers, cookies=cookies)ward = json.loads(r.text)#print("ward: " + str(ward))membersInWard, membersWithCalling = parseWardData(json.loads(r.text))membersInStakeWithCalling = membersInStakeWithCalling + membersWithCallingmembersInStake = membersInStake + membersInWardprint("Adult members in Stake: " + str(membersInStake))print("Adult members in Stake with callings: " + str(membersInStakeWithCalling))print("Average estimated adult activity in stake: " + str(membersInStakeWithCalling / membersInStake))
At the top of that program you'll see the following
You need to fill these in for the program to work, once they are filled in you can press the run button and on the right hand side of the screen the results will be printed. Those results will only show you how many adults in your stake have a calling and how many are on the records without a calling. Children are not counted.#javascritp to get unit# window.location.href.substring(window.location.href.lastIndexOf('/')+1)unit=''#javascirpt to get directory_access_token# document.cookie.match(new RegExp('(^| )directory_access_token=([^;]+)'))[2]directoryAccessToken=''#javascript to get directory_identity_token# document.cookie.match(new RegExp('(^| )directory_identity_token=([^;]+)'))[2]directoryIdentityToken=''#have to get bearer from developer toolsbearer=''
Now for the tricky part, filling in the required fields so the program can run.
Using Firefox or Chrome do the following
1) Log in to lds.org, if you don't have a login then you can't do this
2) Navigate to the Directory, you can just go to this link after logging in, https://directory.churchofjesuschrist.org/
3) Open the developer tools by pressing F12 on your keyboard, then click on the Network tab in developer tools
4) Change the drop down on the top left from your ward to "Entire Stake"
5) In the developer tools there is a filter box, in that box type "households", now in the list you should only see a few requests for the households in the various wards in your stake.
6) click on one and get the Authorization bearer token from the request headers, you will probably have to scroll down on the right hand side, you need to look for "Authorization: Bearer " and then copy the long block of text after Bearer until the next field, in this case you can see the next field is "Connection: keep-alive"
7) paste just the token after the word Bearer into the python program into the field called bearer. So it should look like bearer='somelongrandomstring' when you are done
8) Run the three javascript commands in the console to get the other three values you need for the script to work. Copy each string and paste it into the console and then press enter.
This will get you the unit
window.location.href.substring(window.location.href.lastIndexOf('/')+1)
This will get you the directoryAccessToken
document.cookie.match(new RegExp('(^| )directory_access_token=([^;]+)'))[2]
This will get you the directoryIdentityToken
document.cookie.match(new RegExp('(^| )directory_identity_token=([^;]+)'))[2]
Adult members in ward: 202Adult members with callings: 109Adult members without a calling: 93Adult members with multiple callings: 27Adult members in the ward with Stake callings: 18Visible children records in the ward: 15Average estimated adult activity in ward: 0.5396039603960396Adult members in ward: 178Adult members with callings: 87Adult members without a calling: 91Adult members with multiple callings: 19Adult members in the ward with Stake callings: 18Visible children records in the ward: 155Average estimated adult activity in ward: 0.4887640449438202You can see in these two wards about half of the adults have a calling, the other half may or may not be active but they don't currently hold a calling.
No comments:
Post a Comment
Comments will be published unless they reveal personal identifying information about the commenter or the author.