lokesh341 commited on
Commit
3fb754c
·
verified ·
1 Parent(s): 27ce268

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -68,7 +68,6 @@ def calculate_scores(vendor_log):
68
  'safetyScore': round(safety_score, 2),
69
  'communicationScore': round(communication_score, 2)
70
  }
71
- # Final Score is calculated in Salesforce via Formula field
72
  return scores
73
  except Exception as e:
74
  logger.error(f"Error calculating scores for Vendor Log {vendor_log['Vendor_Log_ID__c']}: {str(e)}")
@@ -115,16 +114,18 @@ def fetch_and_process_logs():
115
  return
116
 
117
  try:
118
- # Fetch Vendor Logs for the current month
119
- current_month = f"{today.month}-{today.year}"
 
120
  query = """
121
  SELECT Id, Vendor_Log_ID__c, Vendor__c, Vendor__r.Name, Vendor__r.Vendor_Name__c, Vendor__r.Contact_Email__c,
122
  Project__c, Work_Completion_Date__c, Actual_Completion_Date__c, Delay_Days__c,
123
  Quality_Percentage__c, Incident_Severity__c, Communication_Count__c, Work_Completion_Percentage__c
124
  FROM Vendor_Log__c
125
- WHERE Created_Month__c = :current_month
126
  """
127
- result = sf.query(query.replace(':current_month', f"'{current_month}'"))
 
128
  vendor_logs = result['records']
129
 
130
  subcontractor_scores = []
 
68
  'safetyScore': round(safety_score, 2),
69
  'communicationScore': round(communication_score, 2)
70
  }
 
71
  return scores
72
  except Exception as e:
73
  logger.error(f"Error calculating scores for Vendor Log {vendor_log['Vendor_Log_ID__c']}: {str(e)}")
 
114
  return
115
 
116
  try:
117
+ # Fetch Vendor Logs for the current month using CreatedDate
118
+ current_month = today.month
119
+ current_year = today.year
120
  query = """
121
  SELECT Id, Vendor_Log_ID__c, Vendor__c, Vendor__r.Name, Vendor__r.Vendor_Name__c, Vendor__r.Contact_Email__c,
122
  Project__c, Work_Completion_Date__c, Actual_Completion_Date__c, Delay_Days__c,
123
  Quality_Percentage__c, Incident_Severity__c, Communication_Count__c, Work_Completion_Percentage__c
124
  FROM Vendor_Log__c
125
+ WHERE CALENDAR_MONTH(CreatedDate) = :currentMonth AND CALENDAR_YEAR(CreatedDate) = :currentYear
126
  """
127
+ query = query.replace(':currentMonth', str(current_month)).replace(':currentYear', str(current_year))
128
+ result = sf.query(query)
129
  vendor_logs = result['records']
130
 
131
  subcontractor_scores = []