From ca9e0bf05a587c3ded1fdc86af978a1926f9da73 Mon Sep 17 00:00:00 2001 From: Peter Dudfield <34686298+peterdudfield@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:37:13 +0100 Subject: [PATCH] dont get user if its already there (#138) --- pvsite_datamodel/write/database.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pvsite_datamodel/write/database.py b/pvsite_datamodel/write/database.py index 22df847..63d3c04 100644 --- a/pvsite_datamodel/write/database.py +++ b/pvsite_datamodel/write/database.py @@ -17,11 +17,10 @@ def save_api_call_to_db(url, session, user=None): url = str(url) if user is None: email = "unknown" - else: - email = user.email + user = get_user_by_db(session=session, email=email) + + email = user.email - # get user from db - user = get_user_by_db(session=session, email=email) # make api call logger.info(f"Saving api call ({url=}) to database for user {email}") api_request = APIRequestSQL(url=url, user=user)