Skip to content

Commit

Permalink
fix: set all waterings to included_in_map_layer = false first
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaszkowic committed May 28, 2024
1 parent fe8da4b commit c9814c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions harvester/src/mapbox_tree_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ def update_tree_waterings(trees_watered, db_conn):
print(f"Set included_in_map_layer = TRUE for {len(trees_watered)} watered trees...")
tree_ids = [tree_watered[4] for tree_watered in trees_watered]
with db_conn.cursor() as cur:
# Set included_in_map_layer = FALSE for all waterings
cur.execute(
"""
UPDATE trees_watered SET included_in_map_layer = FALSE WHERE TRUE;
""",
(tree_ids,),
)
db_conn.commit()

# Set included_in_map_layer = FALSE for the waterings that are included in this round of the harvester
cur.execute(
"""
UPDATE trees_watered SET included_in_map_layer = TRUE WHERE id = ANY (%s);
Expand Down
1 change: 1 addition & 0 deletions harvester/src/run_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@
database_connection,
)

# Update the tree waterings and flag the waterings which are now included in the mapbox layer with included_in_map_layer = TRUE
update_tree_waterings(trees_watered, database_connection)

0 comments on commit c9814c7

Please sign in to comment.