瀏覽代碼

Add race time

Foppe Hemminga 6 年之前
父節點
當前提交
970718807b
共有 1 個文件被更改,包括 16 次插入6 次删除
  1. 16 6
      main.py

+ 16 - 6
main.py

@@ -74,12 +74,22 @@ if __name__ == '__main__':
                 # report new scratching
                 date_object = datetime.datetime.strptime(scratching.date, "%Y-%m-%d").date()
                 day_abbr = date_object.strftime('%a')
-                message = 'New scratching: venue = {} {} {}-{} | race = {} | horse = {}'.format(day_abbr,
-                                                                                                scratching.date,
-                                                                                                scratching.state,
-                                                                                                scratching.venue,
-                                                                                                scratching.race,
-                                                                                                scratching.horse)
+                query = """
+                    SELECT start_time, utctime FROM race_program 
+                    WHERE race_date = %s AND
+                        venue = %s AND
+                        race = %s;
+                """
+                cursor.execute(query, (scratching.date, scratching.venue, scratching.race))
+                db_data = cursor.fetchone()
+                message = 'venue = {} {} {}-{} | race = {} {} | {} UTC | horse = {}'.format(day_abbr,
+                                                                                            scratching.date,
+                                                                                            scratching.state,
+                                                                                            scratching.venue,
+                                                                                            scratching.race,
+                                                                                            db_data.start_time,
+                                                                                            db_data.utctime,
+                                                                                            scratching.horse)
                 print(message)
                 if broadcast:
                     view.broadcast(message)