From d29528063dfcb43f213024b02d6610610aed5d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E4=B8=BA=E4=B9=8B?= <560397@gree.com.cn> Date: Mon, 20 Nov 2023 14:25:23 +0800 Subject: [PATCH] Update project --- application/dao/log.py | 6 +++--- application/services/log.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/application/dao/log.py b/application/dao/log.py index 9d0a5e6..7a2111b 100644 --- a/application/dao/log.py +++ b/application/dao/log.py @@ -99,7 +99,7 @@ class LogDao: _ = Log.batch_save(result_generator) @classmethod - def parse(cls, start: str, end: str, index: str, sql: str, cfg: dict) -> int: + def parse(cls, start: str, end: str, index: str, sql: str, options: dict) -> int: """ Parse logs from Elasticsearch and save them to MySQL. @@ -108,7 +108,7 @@ class LogDao: end (str): The end date for the logs. index (str): The Elasticsearch index to get logs from. sql (str): The SQL query to get the intent mapping from MySQL. - cfg (dict): The configuration for MySQL. + options (dict): The configuration for MySQL. Returns: int: The total number of logs parsed. @@ -134,7 +134,7 @@ class LogDao: logger.debug('The data is inserting ...') # Get the intent mapping from MySQL. - mapping_list = cls.get_intent_from_mysql(sql, cfg) + mapping_list = cls.get_intent_from_mysql(sql, options) # Process and save the metadata. cls.process_and_save_data(mdata, mapping_list) diff --git a/application/services/log.py b/application/services/log.py index ebf17bc..1b572c1 100644 --- a/application/services/log.py +++ b/application/services/log.py @@ -46,19 +46,19 @@ class LogService: index = current_app.config.Elasticsearch.Index # Retrieve the MySQL configuration from the current application's configuration. - mysql_config = current_app.config.ExtraDB + cfg = current_app.config.ExtraDB # Retrieve the SQL to be executed from the MySQL configuration. - sql = mysql_config.Sql + sql = cfg.Sql # Construct a configuration dictionary for the MySQL database. - cfg = { - 'host': mysql_config.Host, - 'user': mysql_config.User, - 'password': mysql_config.Password, - 'db': mysql_config.DB, - 'port': mysql_config.Port, + options = { + 'host': cfg.Host, + 'user': cfg.User, + 'password': cfg.Password, + 'db': cfg.DB, + 'port': cfg.Port, } # Parse the logs using the LogDao class and return the result. - return LogDao.parse(start_date, end_date, index, sql, cfg) + return LogDao.parse(start_date, end_date, index, sql, options) -- GitLab