-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added metadata to reports (#121)
- Loading branch information
Showing
6 changed files
with
41 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import structlog | ||
from sqlalchemy.orm import Session | ||
|
||
from backend.models.report import Report | ||
from backend.schemas.landsat.landsat_api_by_id_advanced import LandsatAdvancedAPIById | ||
|
||
|
||
def write_report_to_db(scene_id: str, db: Session): | ||
landsat_item = LandsatAdvancedAPIById(scene_id=scene_id).first_result | ||
db.query(Report).filter(scene_id == Report.scene_id).update( | ||
{ | ||
"is_processed": True, | ||
"raw_data": landsat_item.model_dump_json(), | ||
} | ||
) | ||
db.commit() | ||
try: | ||
landsat_item = LandsatAdvancedAPIById(scene_id=scene_id).first_result | ||
print("Processed") | ||
db.query(Report).filter(scene_id == Report.scene_id).update( | ||
{ | ||
"is_processed": True, | ||
"raw_data": landsat_item.model_dump_json(), | ||
} | ||
) | ||
db.commit() | ||
except Exception as e: | ||
structlog.get_logger().error(f"Error while building LandsatItem from {scene_id}: {e}") |
Oops, something went wrong.