fix: 生物由来照会画面で35000件を超える検索をしたとき、件数が多すぎるとサーバーがメモリ不足を起こす問題を修正

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-08-08 17:15:06 +09:00
parent cae31e1ee5
commit b1c65ff3bf
2 changed files with 6 additions and 3 deletions

View File

@ -4,6 +4,7 @@ from src.logging.get_logger import get_logger
from src.model.db.bio_sales_lot import BioSalesLotDBModel
from src.model.request.bio import BioModel
from src.repositories.base_repository import BaseRepository
from src.system_var import environment
from src.util.string_util import is_not_empty
logger = get_logger('生物由来参照')
@ -58,7 +59,8 @@ class BioSalesLotRepository(BaseRepository):
rec_whs_sub_cd,
rev_hsdnymd_srk,
slip_mgt_num
ASC\
ASC
LIMIT {limit}\
"""
def fetch_many(self, parameter: BioModel) -> list[BioSalesLotDBModel]:
@ -66,7 +68,8 @@ class BioSalesLotRepository(BaseRepository):
self._database.connect()
logger.debug('DB参照実行')
where_clause = self.__build_condition(parameter)
query = self.FETCH_SQL.format(where_clause=where_clause)
# システムとしての最大取得件数 +1 まで取る
query = self.FETCH_SQL.format(where_clause=where_clause, limit=environment.BIO_SEARCH_RESULT_MAX_COUNT + 1)
logger.debug(f'SQL: {query}')
result = self._database.execute_select(query, parameter.model_dump())
logger.debug(f'count= {len(result)}')

View File

@ -19,7 +19,7 @@ DB_USERNAME = os.environ['DB_USERNAME']
DB_PASSWORD = os.environ['DB_PASSWORD']
DB_SCHEMA = os.environ['DB_SCHEMA']
BIO_SEARCH_RESULT_MAX_COUNT = int(os.environ['BIO_SEARCH_RESULT_MAX_COUNT'])
BIO_SEARCH_RESULT_MAX_COUNT = int(os.environ.get('BIO_SEARCH_RESULT_MAX_COUNT', 35000))
ULTMARC_SEARCH_RESULT_MAX_COUNT = int(os.environ['ULTMARC_SEARCH_RESULT_MAX_COUNT'])
SESSION_EXPIRE_MINUTE = int(os.environ['SESSION_EXPIRE_MINUTE'])