Add global state module
This commit is contained in:
@ -23,10 +23,11 @@ class ValidShowEpisodeLineRequest(BaseModel):
|
||||
|
||||
class Transcriptions(FastAPI):
|
||||
"""Transcription Endpoints"""
|
||||
def __init__(self, app: FastAPI, util, constants): # pylint: disable=super-init-not-called
|
||||
def __init__(self, app: FastAPI, util, constants, glob_state): # pylint: disable=super-init-not-called
|
||||
self.app = app
|
||||
self.util = util
|
||||
self.constants = constants
|
||||
self.glob_state = glob_state
|
||||
|
||||
self.endpoints = {
|
||||
"transcriptions/get_episodes": self.get_episodes_handler,
|
||||
@ -79,6 +80,7 @@ class Transcriptions(FastAPI):
|
||||
'err': True,
|
||||
'errorText': 'Unknown error.'
|
||||
}
|
||||
await self.glob_state.increment_counter('transcript_list_requests')
|
||||
async with sqlite3.connect(database=db_path, timeout=1) as _db:
|
||||
async with _db.execute(db_query) as _cursor:
|
||||
result = await _cursor.fetchall()
|
||||
@ -114,7 +116,8 @@ class Transcriptions(FastAPI):
|
||||
'err': True,
|
||||
'errorText': 'Unknown error'
|
||||
}
|
||||
|
||||
|
||||
await self.glob_state.increment_counter('transcript_requests')
|
||||
async with sqlite3.connect(database=db_path, timeout=1) as _db:
|
||||
params = (episode_id,)
|
||||
async with _db.execute(db_query, params) as _cursor:
|
||||
|
Reference in New Issue
Block a user