|
|
|
@ -291,7 +291,7 @@ def doQueryAlgorithm(query:query_data) -> dict: |
|
|
|
# TODO: if query_obj.media_type is still 'UNKNOWN' from parseQueryStr(), make queries to |
|
|
|
# TODO: if query_obj.media_type is still 'UNKNOWN' from parseQueryStr(), make queries to |
|
|
|
# both tmdb endpoints (movie and tv) |
|
|
|
# both tmdb endpoints (movie and tv) |
|
|
|
if query.raw_query_str and parseQueryStr(query): |
|
|
|
if query.raw_query_str and parseQueryStr(query): |
|
|
|
if isQueryCached(query.parsed_query_str): |
|
|
|
if isQueryCached(query.parsed_query_str, query.movie_year): |
|
|
|
view_results = makeLocalQuery(query) |
|
|
|
view_results = makeLocalQuery(query) |
|
|
|
current_app.logger.debug(f'view_results length: {len(view_results)}') |
|
|
|
current_app.logger.debug(f'view_results length: {len(view_results)}') |
|
|
|
elif makeTMDBQuery(query, response): |
|
|
|
elif makeTMDBQuery(query, response): |
|
|
|
@ -351,12 +351,12 @@ def parseQueryStr(query_obj): |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def isQueryCached(query_str): |
|
|
|
def isQueryCached(query_str:str, year) -> bool: |
|
|
|
conn = db.get_db() |
|
|
|
conn = db.get_db() |
|
|
|
cur = conn.cursor() |
|
|
|
cur = conn.cursor() |
|
|
|
cur.execute('SELECT COUNT(*) FROM query_cache WHERE query=?', (query_str,)) |
|
|
|
cur.execute('SELECT COUNT(*) FROM query_cache WHERE query=? AND year=?', (query_str, year)) |
|
|
|
count = cur.fetchone()[0] |
|
|
|
count = cur.fetchone()[0] |
|
|
|
current_app.logger.debug(f'query_cache count: {count}, query: "{query_str}"') |
|
|
|
current_app.logger.debug(f'query_cache count: {count}, query: "{query_str}", year: {year}') |
|
|
|
|
|
|
|
|
|
|
|
return (count > 0) |
|
|
|
return (count > 0) |
|
|
|
|
|
|
|
|
|
|
|
|