]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/blobdiff - scripts/query_sledrun_list.py
Add length column to sledrun list.
[philipp/winterrodeln/wrpylib.git] / scripts / query_sledrun_list.py
index e4ac49ebb593688300d290852f9acf58f8e24ffb..ca393465af7cd6a3593f90bff0239577bc379456 100644 (file)
@@ -51,6 +51,7 @@ def create_sledrun_list(connection: Connection, api_url: str):
         "JSON_EXTRACT(sledrun_json, '$.name') as name, " \
         "JSON_EXTRACT(sledrun_json, '$.position.longitude') as latitude, " \
         "JSON_EXTRACT(sledrun_json, '$.position.latitude') as longitude, " \
+        "JSON_EXTRACT(sledrun_json, '$.length') as length, " \
         "JSON_EXTRACT(sledrun_json, '$.entry_under_construction') as under_construction, " \
         "page_title as title " \
         "FROM wrsledrunjsoncache JOIN page ON sledrun_page_id=page_id " \
@@ -58,11 +59,11 @@ def create_sledrun_list(connection: Connection, api_url: str):
     rows = connection.execute(sql)
 
     writer = csv.writer(sys.stdout, lineterminator='\n')
-    writer.writerow(['Name', 'Longitude', 'Latitude', 'InArbeit', 'Url'])
+    writer.writerow(['Name', 'Length', 'Longitude', 'Latitude', 'InArbeit', 'Url'])
     for row in rows:
         title = row['title'].decode('utf-8')
         url = urllib.parse.urljoin(api_url, title)
-        writer.writerow([json.loads(row['name']), row['latitude'], row['longitude'], row['under_construction'], url])
+        writer.writerow([json.loads(row['name']), row['length'], row['latitude'], row['longitude'], row['under_construction'], url])
 
 
 def query_sledrun_list(inifiles: List[str]):