Skip to content

Commit

Permalink
Merge commit 'd1c5c6ed61aaa4ad5b24b87cb542149d267d048f' into update-tilt
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Sep 24, 2024
2 parents 771320a + d1c5c6e commit c6d45fd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/update_tilt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
""" We noticed that for lots of the passive sites, the tilt was wrong in the database."""

import os
from pvconsumer.solar_sheffield_passiv import get_all_systems_from_solar_sheffield

from pvsite_datamodel.connection import DatabaseConnection
from pvsite_datamodel.read.site import get_all_sites

from pvconsumer.solar_sheffield_passiv import get_all_systems_from_solar_sheffield

url = os.getenv("SS_URL")
user_id = os.getenv("SS_USER_ID")
key = os.getenv("SS_KEY")
Expand All @@ -20,7 +22,9 @@
sites_found = 0

for site in sites:
all_pv_systems_df_temp = all_pv_systems_df[all_pv_systems_df['pv_system_id'] == site.client_site_id]
all_pv_systems_df_temp = all_pv_systems_df[
all_pv_systems_df["pv_system_id"] == site.client_site_id
]

if len(all_pv_systems_df_temp) == 0:
print(f"Site {site.client_site_id} not found in solar sheffield")
Expand All @@ -31,13 +35,12 @@
old_tilt = site.tilt
new_tilt = all_pv_systems_df_temp.iloc[0].tilt
print(f"Old tilt: {old_tilt}, new tilt: {new_tilt}")
if new_tilt != 'None':
if new_tilt != "None":
new_tilt = float(new_tilt)

if (new_tilt != 'None') and (new_tilt is not None) and (old_tilt != new_tilt):
if (new_tilt != "None") and (new_tilt is not None) and (old_tilt != new_tilt):
site.tilt = new_tilt
print(f"Updated tilt for site {site.client_site_id} from {old_tilt} to {new_tilt}")
session.commit()


print(f"Found {sites_found} sites in solar sheffield")

0 comments on commit c6d45fd

Please sign in to comment.