Update app.py
Browse files
app.py
CHANGED
@@ -127,16 +127,21 @@ def reward_status():
|
|
127 |
return "User not logged in", 400
|
128 |
|
129 |
# Query Salesforce to fetch the user's reward points
|
130 |
-
|
131 |
-
|
|
|
|
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
|
|
|
|
|
|
|
140 |
# Define point ranges for each tier
|
141 |
tiers = {
|
142 |
"Bronze": 1,
|
@@ -144,7 +149,7 @@ def reward_status():
|
|
144 |
"Gold": 300,
|
145 |
"Platinum": 500
|
146 |
}
|
147 |
-
|
148 |
# Get the user's current tier and the points required for the next tier
|
149 |
current_tier = ""
|
150 |
points_needed_for_next_tier = 0
|
@@ -172,6 +177,7 @@ def reward_status():
|
|
172 |
points_needed_for_next_tier=points_needed_for_next_tier,
|
173 |
progress_percentage=progress_percentage
|
174 |
)
|
|
|
175 |
@app.route("/logout")
|
176 |
def logout():
|
177 |
# Retrieve table number before clearing session
|
|
|
127 |
return "User not logged in", 400
|
128 |
|
129 |
# Query Salesforce to fetch the user's reward points
|
130 |
+
try:
|
131 |
+
# Query the Customer_Login__c object based on the user's email
|
132 |
+
query = f"SELECT Id, Reward_Points__c FROM Customer_Login__c WHERE Email__c = '{email}'"
|
133 |
+
user_data = sf.query(query)
|
134 |
|
135 |
+
# Check if the user record was found
|
136 |
+
if not user_data.get("records"):
|
137 |
+
return "User not found", 400
|
138 |
+
|
139 |
+
# Get the user's reward points from Salesforce
|
140 |
+
user_points = user_data["records"][0].get("Reward_Points__c", 0)
|
141 |
|
142 |
+
except Exception as e:
|
143 |
+
return f"Error querying Salesforce: {str(e)}", 500
|
144 |
+
|
145 |
# Define point ranges for each tier
|
146 |
tiers = {
|
147 |
"Bronze": 1,
|
|
|
149 |
"Gold": 300,
|
150 |
"Platinum": 500
|
151 |
}
|
152 |
+
|
153 |
# Get the user's current tier and the points required for the next tier
|
154 |
current_tier = ""
|
155 |
points_needed_for_next_tier = 0
|
|
|
177 |
points_needed_for_next_tier=points_needed_for_next_tier,
|
178 |
progress_percentage=progress_percentage
|
179 |
)
|
180 |
+
|
181 |
@app.route("/logout")
|
182 |
def logout():
|
183 |
# Retrieve table number before clearing session
|