Fix route config
Fix fts search Log exceptions
This commit is contained in:
+1
-1
@@ -42,7 +42,7 @@ async def list_locations(
|
|||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
@api.get('/diyanet/search', response_model=List[PrayerTimes])
|
@api.get('/diyanet/search', response_model=List[Location])
|
||||||
async def search_location(
|
async def search_location(
|
||||||
q: str,
|
q: str,
|
||||||
conn: sqlite3.Connection = Depends(get_connection)):
|
conn: sqlite3.Connection = Depends(get_connection)):
|
||||||
|
|||||||
+10
@@ -1,6 +1,16 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from loguru import logger
|
||||||
|
from starlette.requests import Request
|
||||||
|
|
||||||
from app.api import api as api_router
|
from app.api import api as api_router
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
app.include_router(api_router, prefix='/api')
|
app.include_router(api_router, prefix='/api')
|
||||||
|
|
||||||
|
|
||||||
|
@app.exception_handler(Exception)
|
||||||
|
async def log_exceptions(req: Request, err: Exception):
|
||||||
|
try:
|
||||||
|
raise err
|
||||||
|
except:
|
||||||
|
logger.exception(err)
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ def find_location_by_name(conn: sqlite3.Connection, q: str) -> List[Location]:
|
|||||||
WHERE locations_search match :q
|
WHERE locations_search match :q
|
||||||
ORDER BY country, city, region
|
ORDER BY country, city, region
|
||||||
'''
|
'''
|
||||||
stmt = conn.execute(sql, {'q': f'%{q}%'})
|
stmt = conn.execute(sql, {'q': f'{q}'})
|
||||||
rows = stmt.fetchall()
|
rows = stmt.fetchall()
|
||||||
if not rows:
|
if not rows:
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user