Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamez committed Dec 4, 2024
1 parent dbb0221 commit f308820
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions api/src/feeds/impl/feeds_api_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
LocationTranslation,
get_feeds_location_translations,
)
from utils.logger import Logger

T = TypeVar("T", bound="BasicFeed")

Expand All @@ -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))
Expand All @@ -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()
Expand All @@ -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
)
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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(
Expand Down

0 comments on commit f308820

Please sign in to comment.