diff --git a/application/dao/log.py b/application/dao/log.py index 9d0a5e60d4b68a860928dbf724040df25b3228bf..7a2111bb866fd031801bcce735cea2be523d7fc2 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 ebf17bc3c4a0d6b67aedb833590e879afb7d6a85..1b572c18e6fdbbc8759e20366ccbf53a2a80981f 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)