Ver Fonte

fix previous

ming há 4 anos atrás
pai
commit
dca9afb1dc
1 ficheiros alterados com 11 adições e 2 exclusões
  1. 11 2
      newbot.py

+ 11 - 2
newbot.py

@@ -152,9 +152,13 @@ async def callback(request: fastapi.Request):
     return 'OK'
 
 @app.get('/get_trend_image')
-async def get_trend_image(kw):
+async def get_trend_image(kw_id):
 #def get_trend_image(kw):
     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/yodb?charset=utf8mb4')
+    kw = ''
+    sql_get_newest_data_date = 'SELECT iot_kword FROM interest_over_time WHERE iotid="'+kw_id+'"'
+    for row in db.query(sql_get_newest_data_date):
+        kw=row['iot_kword']
     sql_get_newest_data_date = 'SELECT * FROM interest_over_time WHERE iot_kword="'+kw+'" ORDER BY iot_date'
     x_axis = []
     y_axis = []
@@ -221,11 +225,16 @@ def flex_test():
         js['body']['contents'] = js['body']['contents'] + [row_dict]
     return js
 def make_bubble(title,kw):
+    db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/yodb?charset=utf8mb4')
+    sql_get_newest_data_date = 'SELECT iotid FROM interest_over_time WHERE iot_kword="'+kw+'"'
+    id=''
+    for row in db.query(sql_get_newest_data_date):
+        id=row['iotid']
     box_dict = {
       "type": "bubble",
       "hero": {
         "type": "image",
-        "url": "https://api.ptt.cx:6443/get_trend_image?kw="+kw,
+        "url": "https://api.ptt.cx:6443/get_trend_image?kw_id="+id,
         "size": "full",
         "gravity": "top",
         "margin": "none",