Skip to content

Commit b1d449b

Browse files
authored
Fix/disco 3806 init (#1152)
* fix: Ensure that the SportsData index is created Issue: DISCO-3806 * f fmt
1 parent 581e043 commit b1d449b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

merino/jobs/sportsdata_jobs/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def __init__(
119119
async def update(self, include_teams: bool = True, client: AsyncClient | None = None) -> bool:
120120
"""Perform sport specific updates."""
121121
logger = logging.getLogger(__name__)
122+
logger.debug(f"{LOGGING_TAG} Initializing database")
123+
await self.store.startup()
122124
client = create_http_client(
123125
connect_timeout=self.connect_timeout, request_timeout=self.read_timeout
124126
)
@@ -150,13 +152,15 @@ async def update(self, include_teams: bool = True, client: AsyncClient | None =
150152
async def nightly(self, client: AsyncClient | None = None) -> None:
151153
"""Perform the nightly maintenance tasks"""
152154
logger = logging.getLogger(__name__)
155+
logger.debug(f"{LOGGING_TAG} Initializing database")
156+
await self.store.startup()
153157
# Fetch the meta data for the sport, this includes if the sport is "active"
154158
# as well as any upcoming events for the sport.
155159
logger.debug(f"{LOGGING_TAG} Nightly update...")
156160
await self.update(include_teams=True, client=client)
157161
await self.store.prune()
158162

159-
async def initialize(self, settings: LazySettings) -> None:
163+
async def initialize(self) -> None:
160164
"""Initialize the ElasticSearch data store"""
161165
await self.store.build_indexes(clear=False)
162166

@@ -185,9 +189,6 @@ async def initialize(self, settings: LazySettings) -> None:
185189
name = sports_settings.get("platform", "sports")
186190
platform = f"{{lang}}_{name}"
187191
event_map = sports_settings.get("event_index", f"{platform}_event")
188-
dsn = sports_settings.es.get(
189-
"dsn",
190-
)
191192
store = SportsDataStore(
192193
dsn=sports_settings.es.dsn,
193194
api_key=sports_settings.es.api_key,

0 commit comments

Comments
 (0)