Commit d2952806 authored by 崔为之's avatar 崔为之 💪🏽

Update project

parent ca65d190
......@@ -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)
......
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment