Skip to content

Commit f308820

Browse files
committed
add logging
1 parent dbb0221 commit f308820

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

api/src/feeds/impl/feeds_api_impl.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
LocationTranslation,
4747
get_feeds_location_translations,
4848
)
49+
from utils.logger import Logger
4950

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

@@ -59,11 +60,17 @@ class FeedsApiImpl(BaseFeedsApi):
5960

6061
APIFeedType = Union[BasicFeed, GtfsFeed, GtfsRTFeed]
6162

63+
def __init__(self) -> None:
64+
self.logger = Logger("FeedsApiImpl").get_logger()
65+
6266
def get_feed(
6367
self,
6468
id: str,
6569
) -> BasicFeed:
6670
"""Get the specified feed from the Mobility Database."""
71+
is_email_restricted = is_user_email_restricted()
72+
self.logger.info(f"User email is restricted: {is_email_restricted}")
73+
6774
feed = (
6875
FeedFilter(stable_id=id, provider__ilike=None, producer_url__ilike=None, status=None)
6976
.filter(Database().get_query_model(Feed))
@@ -72,7 +79,7 @@ def get_feed(
7279
or_(
7380
Feed.operational_status == None, # noqa: E711
7481
Feed.operational_status != "wip",
75-
not is_user_email_restricted(), # Allow all feeds to be returned if the user is not restricted
82+
not is_email_restricted, # Allow all feeds to be returned if the user is not restricted
7683
)
7784
)
7885
.first()
@@ -91,6 +98,8 @@ def get_feeds(
9198
producer_url: str,
9299
) -> List[BasicFeed]:
93100
"""Get some (or all) feeds from the Mobility Database."""
101+
is_email_restricted = is_user_email_restricted()
102+
self.logger.info(f"User email is restricted: {is_email_restricted}")
94103
feed_filter = FeedFilter(
95104
status=status, provider__ilike=provider, producer_url__ilike=producer_url, stable_id=None
96105
)
@@ -100,7 +109,7 @@ def get_feeds(
100109
or_(
101110
Feed.operational_status == None, # noqa: E711
102111
Feed.operational_status != "wip",
103-
not is_user_email_restricted(), # Allow all feeds to be returned if the user is not restricted
112+
not is_email_restricted, # Allow all feeds to be returned if the user is not restricted
104113
)
105114
)
106115
# Results are sorted by provider
@@ -239,6 +248,8 @@ def get_gtfs_feeds(
239248
subquery, dataset_latitudes, dataset_longitudes, bounding_filter_method
240249
).subquery()
241250

251+
is_email_restricted = is_user_email_restricted()
252+
self.logger.info(f"User email is restricted: {is_email_restricted}")
242253
feed_query = (
243254
Database()
244255
.get_session()
@@ -248,7 +259,7 @@ def get_gtfs_feeds(
248259
or_(
249260
Gtfsfeed.operational_status == None, # noqa: E711
250261
Gtfsfeed.operational_status != "wip",
251-
not is_user_email_restricted(), # Allow all feeds to be returned if the user is not restricted
262+
not is_email_restricted, # Allow all feeds to be returned if the user is not restricted
252263
)
253264
)
254265
.options(

0 commit comments

Comments
 (0)