Created
November 2, 2018 19:12
-
-
Save javierwilson/b7e81d61903c7f7d53b8f69d3f5fb9ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
projects = sf.query_all("SELECT Id, Name, Project_Identifier__c, Project_Type__c, LWR_Region__c, Start_Date__c, End_Date__c FROM Project__c WHERE RecordTypeId <> '0120Z0000016F8q' AND End_Date__c >= 2017-09-30") | |
i = 1 | |
objs = ['Agriculture__c', 'Climate_Change__c', 'Constituent_Engagement__c', 'Emergency_Operations__c', 'Civic_Participation__c', 'Health_Livelihood__c', 'Water__c', 'Other__c'] | |
objs_string = ",".join(objs) | |
print "Number,Id,Project_Identifier__c,Project_Type__c,LWR_Region__c,Start_Date__c,End_Date__c,Name,%s" % (objs_string) | |
for item in projects['records']: | |
subs = sf.query_all("SELECT Id, %s FROM Sub_Project__c WHERE Project__r.Id='%s'" % (objs_string, item['Id'])) | |
data = {} | |
for o in objs: | |
data[o] = 0 | |
for sitem in subs['records']: | |
for o in objs: | |
if (sitem[o]): | |
data[o] += sitem[o] | |
print "%s,%s,%s,%s,%s,%s,%s,\"%s\",%s,%s,%s,%s,%s,%s,%s,%s" % (i, item['Id'], item['Project_Identifier__c'], item['Project_Type__c'], item['LWR_Region__c'], item['Start_Date__c'], item['End_Date__c'], item['Name'], data['Agriculture__c'], data['Climate_Change__c'], data['Constituent_Engagement__c'], data['Emergency_Operations__c'], data['Civic_Participation__c'], data['Health_Livelihood__c'], data['Water__c'], data['Other__c']) | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment