Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize generating project data #2214

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

Sujanadh
Copy link
Collaborator

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation
  • πŸ§‘β€πŸ’» Refactor
  • βœ… Test
  • πŸ€– Build or CI
  • ❓ Other (please specify)

Related Issue

Describe this PR

  • Optimized fetching fgb data from s3 using aiohttp
  • Refactored sql that converts fgb to geojson using materialized view
  • Simplified sql that splits geojson by task areas using batch insertion
  • Simplified adding required properties to geojson

Screenshots

N/A

Alternative Approaches Considered

Did you attempt any other approaches that are not documented in code?

Review Guide

Notes for the reviewer. How to test this change?

Checklist before requesting a review

[optional] What gif best describes this PR or how it makes you feel?

@Sujanadh Sujanadh requested a review from spwoodcock February 19, 2025 11:58
@Sujanadh Sujanadh self-assigned this Feb 19, 2025
@github-actions github-actions bot added enhancement New feature or request backend Related to backend code labels Feb 19, 2025
Copy link
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nice updates!

I think there could be some logic issues that I commented on, but could be wrong πŸ˜„

Let me know your thoughts

for f in batch
]

async with db.cursor() as cur:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will open a cursor for every feature in the project surely, as it's in the for loop?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous approach inserted the featcol all in one go I think

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you are right i can change that to use one cursor for all the batches.

@@ -353,43 +311,31 @@ def add_required_geojson_properties(
This step is required prior to flatgeobuf generation,
else the workflows of conversion between the formats will fail.
"""
for feature in geojson.get("features", []):
properties = feature.get("properties", {})
current_timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a helper function from postgis_utils timestamp() that returns a current timezone aware timestamp in UTC

@Sujanadh Sujanadh marked this pull request as draft February 20, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants