
--- action.py
+++ action.py
... | ... | @@ -23,6 +23,7 @@ |
23 | 23 |
'abrupt_stop_count': fields.Integer(required=True, description='Count of abrupt stops'), |
24 | 24 |
'abrupt_acceleration_count': fields.Integer(required=True, description='Count of abrupt accelerations'), |
25 | 25 |
'abrupt_deceleration_count': fields.Integer(required=True, description='Count of abrupt decelerations'), |
26 |
+ 'turn_noslow_cnt' : fields.Integer(required=True, description='count of abrupt truns'), |
|
26 | 27 |
'helmet_on': fields.Integer(required=True, description='Whether the helmet was worn during the trip, must be 0 or 1 with 1 is the helmet on.'), |
27 | 28 |
'final_score': fields.Float(required=True, description='The final safety score for the trip') |
28 | 29 |
}) |
... | ... | @@ -69,8 +70,8 @@ |
69 | 70 |
return { |
70 | 71 |
500: f"ERROR! Mismatching length of data in trip_log! \n timestamp : {time_stamp_len} \n latitude : {latitude_len} \n longitude : {longitude_len}" |
71 | 72 |
} |
72 |
- with pd.option_context('display.max_rows', None, 'display.max_columns', None): |
|
73 |
- print(data) |
|
73 |
+ # with pd.option_context('display.max_rows', None, 'display.max_columns', None): |
|
74 |
+ # print(data) |
|
74 | 75 |
df = pd.DataFrame(data["trip_log"]) |
75 | 76 |
df["user_id"] = data["user_id"] |
76 | 77 |
df["trip_id"] = data["trip_id"] |
... | ... | @@ -158,15 +159,16 @@ |
158 | 159 |
data = request.get_json() |
159 | 160 |
if len(data["trip_id"]) != 64: |
160 | 161 |
return {"result" : "ERROR! INVALID TRIP_ID!"}, 500 |
161 |
- |
|
162 |
+ print(data) |
|
162 | 163 |
trip_id = data["trip_id"] |
163 | 164 |
trip_distance_m = data["total_distance_m"] |
164 |
- trip_time_s = data["total_time_s"] |
|
165 |
- abrupt_start_count = data["abrupt_start_count"] |
|
166 |
- abrupt_stop_count = data["abrupt_stop_count"] |
|
167 |
- abrupt_acceleration_count = data["abrupt_acceleration_count"] |
|
168 |
- abrupt_deceleration_count = data["abrupt_deceleration_count"] |
|
165 |
+ trip_time_s = data["total_time_sec"] |
|
166 |
+ abrupt_start_count = data["sudden_start_cnt"] |
|
167 |
+ abrupt_stop_count = data["sudden_stop_cnt"] |
|
168 |
+ abrupt_acceleration_count = data["sudden_accel_cnt"] |
|
169 |
+ abrupt_deceleration_count = data["sudden_decel_cnt"] |
|
169 | 170 |
helmet_on = helmet_on = 1 if data["helmet_on"] == "true" else 0 |
171 |
+ trun_noslow_cnt = data["turn_noslow_cnt"] |
|
170 | 172 |
final_score = data["final_score"] |
171 | 173 |
|
172 | 174 |
if (helmet_on != 1) and (helmet_on != 0): |
... | ... | @@ -180,6 +182,7 @@ |
180 | 182 |
abrupt_stop_count, |
181 | 183 |
abrupt_acceleration_count, |
182 | 184 |
abrupt_deceleration_count, |
185 |
+ trun_noslow_cnt, |
|
183 | 186 |
helmet_on, |
184 | 187 |
final_score |
185 | 188 |
) |
--- database/database.py
+++ database/database.py
... | ... | @@ -301,13 +301,14 @@ |
301 | 301 |
abrupt_acceleration_count, |
302 | 302 |
abrupt_deceleration_count, |
303 | 303 |
helmet_on, |
304 |
+ turn_noslow_cnt, |
|
304 | 305 |
final_score |
305 | 306 |
): |
306 | 307 |
|
307 | 308 |
self.cur.execute(f""" |
308 | 309 |
INSERT INTO trip_log (user_id, trip_id, timestamp, total_distance_m, total_time_s, abrupt_start_count, abrupt_stop_count, |
309 |
- abrupt_acceleration_count, abrupt_deceleration_count, helmet_on, final_score) |
|
310 |
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) |
|
310 |
+ abrupt_acceleration_count, abrupt_deceleration_count, helmet_on, turn_noslow_cnt, final_score) |
|
311 |
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) |
|
311 | 312 |
""", ( |
312 | 313 |
username, |
313 | 314 |
trip_id, |
... | ... | @@ -319,6 +320,7 @@ |
319 | 320 |
abrupt_acceleration_count, |
320 | 321 |
abrupt_deceleration_count, |
321 | 322 |
helmet_on, |
323 |
+ turn_noslow_cnt, |
|
322 | 324 |
final_score |
323 | 325 |
) |
324 | 326 |
) |
... | ... | @@ -408,7 +410,7 @@ |
408 | 410 |
self.cur.execute(""" |
409 | 411 |
SELECT trip_id, timestamp, total_distance_m, total_time_s, abrupt_start_count, |
410 | 412 |
abrupt_stop_count, abrupt_acceleration_count, abrupt_deceleration_count, |
411 |
- helmet_on, final_score |
|
413 |
+ helmet_on, turn_noslow_cnt, final_score |
|
412 | 414 |
FROM trip_log |
413 | 415 |
WHERE user_id = %s |
414 | 416 |
ORDER BY timestamp DESC |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?