Files changed (1) hide show
  1. app.py +62 -23
app.py CHANGED
@@ -130,25 +130,46 @@ def create_salesforce_reports(df):
130
  usage_report_metadata = {
131
  "reportMetadata": {
132
  "name": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
133
- "reportType": "SmartLog__c",
 
 
 
 
134
  "reportFormat": "SUMMARY",
 
135
  "reportFilters": [
136
- {"column": "Status__c", "operator": "equals", "value": "Active"},
137
- {"column": "Timestamp__c", "operator": "greaterOrEqual", "value": "THIS_MONTH"}
138
- ],
139
- "reportColumns": [
140
- {"field": "Device_Id__c"},
141
- {"field": "Log_Type__c"},
142
- {"field": "Status__c"},
143
- {"field": "Timestamp__c"},
144
- {"field": "Usage_Hours__c", "aggregateTypes": ["Sum"]},
145
- {"field": "Downtime__c", "aggregateTypes": ["Sum"]},
146
- {"field": "AMC_Date__c"}
147
  ],
 
148
  "groupingsDown": [
149
- {"field": "Device_Id__c", "sortOrder": "Asc", "dateGranularity": "None"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  ],
151
- "folderId": LABOPS_REPORTS_FOLDER_ID
 
152
  }
153
  }
154
  usage_result = sf.restful('analytics/reports', method='POST', json=usage_report_metadata)
@@ -159,19 +180,37 @@ def create_salesforce_reports(df):
159
  amc_report_metadata = {
160
  "reportMetadata": {
161
  "name": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
162
- "reportType": "SmartLog__c",
 
 
 
 
163
  "reportFormat": "TABULAR",
 
164
  "reportFilters": [
165
- {"column": "Status__c", "operator": "equals", "value": "Active"},
166
- {"column": "AMC_Date__c", "operator": "greaterOrEqual", "value": "TODAY"},
167
- {"column": "AMC_Date__c", "operator": "lessOrEqual", "value": "NEXT_N_DAYS:30"}
 
 
 
 
 
 
 
 
 
 
 
 
168
  ],
169
- "reportColumns": [
170
- {"field": "Device_Id__c"},
171
- {"field": "AMC_Date__c"},
172
- {"field": "Status__c"}
173
  ],
174
- "folderId": LABOPS_REPORTS_FOLDER_ID
 
175
  }
176
  }
177
  amc_result = sf.restful('analytics/reports', method='POST', json=amc_report_metadata)
 
130
  usage_report_metadata = {
131
  "reportMetadata": {
132
  "name": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
133
+ "developerName": f"SmartLog_Usage_Report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
134
+ "reportType": {
135
+ "type": "CustomObject",
136
+ "value": "SmartLog__c"
137
+ },
138
  "reportFormat": "SUMMARY",
139
+ "reportBooleanFilter": None,
140
  "reportFilters": [
141
+ {
142
+ "column": "SmartLog__c.Status__c",
143
+ "operator": "equals",
144
+ "value": "Active"
145
+ },
146
+ {
147
+ "column": "SmartLog__c.Timestamp__c",
148
+ "operator": "greaterOrEqual",
149
+ "value": "THIS_MONTH"
150
+ }
 
151
  ],
152
+ "aggregates": ["s!SmartLog__c.Usage_Hours__c", "s!SmartLog__c.Downtime__c"],
153
  "groupingsDown": [
154
+ {
155
+ "name": "Device_Id__c",
156
+ "field": "SmartLog__c.Device_Id__c",
157
+ "sortOrder": "Asc",
158
+ "sortAggregate": None,
159
+ "dateGranularity": "None"
160
+ }
161
+ ],
162
+ "detailColumns": [
163
+ "SmartLog__c.Device_Id__c",
164
+ "SmartLog__c.Log_Type__c",
165
+ "SmartLog__c.Status__c",
166
+ "SmartLog__c.Timestamp__c",
167
+ "SmartLog__c.Usage_Hours__c",
168
+ "SmartLog__c.Downtime__c",
169
+ "SmartLog__c.AMC_Date__c"
170
  ],
171
+ "folderId": LABOPS_REPORTS_FOLDER_ID,
172
+ "currency": None
173
  }
174
  }
175
  usage_result = sf.restful('analytics/reports', method='POST', json=usage_report_metadata)
 
180
  amc_report_metadata = {
181
  "reportMetadata": {
182
  "name": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
183
+ "developerName": f"SmartLog_AMC_Reminders_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
184
+ "reportType": {
185
+ "type": "CustomObject",
186
+ "value": "SmartLog__c"
187
+ },
188
  "reportFormat": "TABULAR",
189
+ "reportBooleanFilter": None,
190
  "reportFilters": [
191
+ {
192
+ "column": "SmartLog__c.Status__c",
193
+ "operator": "equals",
194
+ "value": "Active"
195
+ },
196
+ {
197
+ "column": "SmartLog__c.AMC_Date__c",
198
+ "operator": "greaterOrEqual",
199
+ "value": "TODAY"
200
+ },
201
+ {
202
+ "column": "SmartLog__c.AMC_Date__c",
203
+ "operator": "lessOrEqual",
204
+ "value": "NEXT_N_DAYS:30"
205
+ }
206
  ],
207
+ "detailColumns": [
208
+ "SmartLog__c.Device_Id__c",
209
+ "SmartLog__c.AMC_Date__c",
210
+ "SmartLog__c.Status__c"
211
  ],
212
+ "folderId": LABOPS_REPORTS_FOLDER_ID,
213
+ "currency": None
214
  }
215
  }
216
  amc_result = sf.restful('analytics/reports', method='POST', json=amc_report_metadata)