Updated the operations dashboard to include a rain outlook feature, providing users with a 7-day forecast based on site coordinates. Added latitude and longitude fields to the site form for better weather data integration. Enhanced the fuel log and site management functionalities to utilize dynamic fuel pricing based on historical data. Improved overall data handling and user experience across various dashboard components.
21 lines
771 B
Python
21 lines
771 B
Python
#!/usr/bin/env python3
|
|
"""Print every site with its coordinates. Read-only.
|
|
|
|
python3 scripts/pb-show-sites.py
|
|
"""
|
|
from pb_env import http, superuser_token
|
|
|
|
TOKEN = superuser_token()
|
|
|
|
code, resp = http("GET", "/api/collections/sites/records?perPage=200", token=TOKEN)
|
|
if code != 200:
|
|
raise SystemExit(f"could not list sites: {code} {resp}")
|
|
|
|
items = resp.get("items", [])
|
|
print(f"\n{len(items)} site(s):\n")
|
|
for s in items:
|
|
lat = s.get("latitude")
|
|
lng = s.get("longitude")
|
|
where = f"{lat}, {lng}" if lat not in (None, "") and lng not in (None, "") else "— no coordinates —"
|
|
print(f" {s.get('name', '?'):<28} {s.get('project_code', ''):<10} {where}")
|
|
print(f" id={s['id']} job_start_date={s.get('job_start_date', '<field absent>')!r}")
|