From f308820f5ad516b61e727e0392e73e059d537cf9 Mon Sep 17 00:00:00 2001 From: David Gamez Diaz <1192523+davidgamez@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:27:22 -0500 Subject: [PATCH] add logging --- api/src/feeds/impl/feeds_api_impl.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/api/src/feeds/impl/feeds_api_impl.py b/api/src/feeds/impl/feeds_api_impl.py index 998090152..f538540cb 100644 --- a/api/src/feeds/impl/feeds_api_impl.py +++ b/api/src/feeds/impl/feeds_api_impl.py @@ -46,6 +46,7 @@ LocationTranslation, get_feeds_location_translations, ) +from utils.logger import Logger T = TypeVar("T", bound="BasicFeed") @@ -59,11 +60,17 @@ class FeedsApiImpl(BaseFeedsApi): APIFeedType = Union[BasicFeed, GtfsFeed, GtfsRTFeed] + def __init__(self) -> None: + self.logger = Logger("FeedsApiImpl").get_logger() + def get_feed( self, id: str, ) -> BasicFeed: """Get the specified feed from the Mobility Database.""" + is_email_restricted = is_user_email_restricted() + self.logger.info(f"User email is restricted: {is_email_restricted}") + feed = ( FeedFilter(stable_id=id, provider__ilike=None, producer_url__ilike=None, status=None) .filter(Database().get_query_model(Feed)) @@ -72,7 +79,7 @@ def get_feed( or_( Feed.operational_status == None, # noqa: E711 Feed.operational_status != "wip", - not is_user_email_restricted(), # Allow all feeds to be returned if the user is not restricted + not is_email_restricted, # Allow all feeds to be returned if the user is not restricted ) ) .first() @@ -91,6 +98,8 @@ def get_feeds( producer_url: str, ) -> List[BasicFeed]: """Get some (or all) feeds from the Mobility Database.""" + is_email_restricted = is_user_email_restricted() + self.logger.info(f"User email is restricted: {is_email_restricted}") feed_filter = FeedFilter( status=status, provider__ilike=provider, producer_url__ilike=producer_url, stable_id=None ) @@ -100,7 +109,7 @@ def get_feeds( or_( Feed.operational_status == None, # noqa: E711 Feed.operational_status != "wip", - not is_user_email_restricted(), # Allow all feeds to be returned if the user is not restricted + not is_email_restricted, # Allow all feeds to be returned if the user is not restricted ) ) # Results are sorted by provider @@ -239,6 +248,8 @@ def get_gtfs_feeds( subquery, dataset_latitudes, dataset_longitudes, bounding_filter_method ).subquery() + is_email_restricted = is_user_email_restricted() + self.logger.info(f"User email is restricted: {is_email_restricted}") feed_query = ( Database() .get_session() @@ -248,7 +259,7 @@ def get_gtfs_feeds( or_( Gtfsfeed.operational_status == None, # noqa: E711 Gtfsfeed.operational_status != "wip", - not is_user_email_restricted(), # Allow all feeds to be returned if the user is not restricted + not is_email_restricted, # Allow all feeds to be returned if the user is not restricted ) ) .options(