Gordon Li commited on
Commit
ee48f73
·
1 Parent(s): dd22c46
Files changed (1) hide show
  1. visualiser/hkust_bnb_visualiser.py +2 -14
visualiser/hkust_bnb_visualiser.py CHANGED
@@ -30,8 +30,7 @@ from constant.hkust_bnb_constant import (
30
  TRAFFIC_SPOT_INFO_TEMPLATE,
31
  RELEVANCE_INFO_TEMPLATE,
32
  POPUP_CONTENT_TEMPLATE,
33
- MAP_SCRIPT,
34
- NO_DISCOUNT_INFO_TEMPLATE
35
  )
36
 
37
  class HKUSTBNBVisualiser:
@@ -389,16 +388,10 @@ class HKUSTBNBVisualiser:
389
  discount_info = ""
390
  discounted_price = row['price']
391
 
392
- # Inside the create_map_and_data method
393
  if row['id'] in all_nearest_traffic_spots:
394
  nearest_spot, distance = all_nearest_traffic_spots[row['id']]
395
  discount_rate = nearest_spot.get_discount_rate()
396
 
397
- # Calculate average vehicle count safely
398
- avg_vehicle_count = nearest_spot.avg_vehicle_count
399
- if avg_vehicle_count is None:
400
- avg_vehicle_count = "N/A" # Or calculate it directly here if needed
401
-
402
  if discount_rate > 0:
403
  discounted_price = row['price'] * (1 - discount_rate)
404
  discount_percentage = int(discount_rate * 100)
@@ -407,12 +400,7 @@ class HKUSTBNBVisualiser:
407
  discount_percentage=discount_percentage,
408
  original_price=row['price'],
409
  discounted_price=discounted_price,
410
- avg_vehicle_count=avg_vehicle_count,
411
- observation_count=len(nearest_spot.dataset_rows)
412
- )
413
- else:
414
- discount_info = NO_DISCOUNT_INFO_TEMPLATE.format(
415
- avg_vehicle_count=avg_vehicle_count,
416
  observation_count=len(nearest_spot.dataset_rows)
417
  )
418
 
 
30
  TRAFFIC_SPOT_INFO_TEMPLATE,
31
  RELEVANCE_INFO_TEMPLATE,
32
  POPUP_CONTENT_TEMPLATE,
33
+ MAP_SCRIPT
 
34
  )
35
 
36
  class HKUSTBNBVisualiser:
 
388
  discount_info = ""
389
  discounted_price = row['price']
390
 
 
391
  if row['id'] in all_nearest_traffic_spots:
392
  nearest_spot, distance = all_nearest_traffic_spots[row['id']]
393
  discount_rate = nearest_spot.get_discount_rate()
394
 
 
 
 
 
 
395
  if discount_rate > 0:
396
  discounted_price = row['price'] * (1 - discount_rate)
397
  discount_percentage = int(discount_rate * 100)
 
400
  discount_percentage=discount_percentage,
401
  original_price=row['price'],
402
  discounted_price=discounted_price,
403
+ avg_vehicle_count=nearest_spot.avg_vehicle_count,
 
 
 
 
 
404
  observation_count=len(nearest_spot.dataset_rows)
405
  )
406