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

Update project

parent ca65d190
...@@ -99,7 +99,7 @@ class LogDao: ...@@ -99,7 +99,7 @@ class LogDao:
_ = Log.batch_save(result_generator) _ = Log.batch_save(result_generator)
@classmethod @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. Parse logs from Elasticsearch and save them to MySQL.
...@@ -108,7 +108,7 @@ class LogDao: ...@@ -108,7 +108,7 @@ class LogDao:
end (str): The end date for the logs. end (str): The end date for the logs.
index (str): The Elasticsearch index to get logs from. index (str): The Elasticsearch index to get logs from.
sql (str): The SQL query to get the intent mapping from MySQL. 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: Returns:
int: The total number of logs parsed. int: The total number of logs parsed.
...@@ -134,7 +134,7 @@ class LogDao: ...@@ -134,7 +134,7 @@ class LogDao:
logger.debug('The data is inserting ...') logger.debug('The data is inserting ...')
# Get the intent mapping from MySQL. # 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. # Process and save the metadata.
cls.process_and_save_data(mdata, mapping_list) cls.process_and_save_data(mdata, mapping_list)
......
...@@ -46,19 +46,19 @@ class LogService: ...@@ -46,19 +46,19 @@ class LogService:
index = current_app.config.Elasticsearch.Index index = current_app.config.Elasticsearch.Index
# Retrieve the MySQL configuration from the current application's configuration. # 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. # 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. # Construct a configuration dictionary for the MySQL database.
cfg = { options = {
'host': mysql_config.Host, 'host': cfg.Host,
'user': mysql_config.User, 'user': cfg.User,
'password': mysql_config.Password, 'password': cfg.Password,
'db': mysql_config.DB, 'db': cfg.DB,
'port': mysql_config.Port, 'port': cfg.Port,
} }
# Parse the logs using the LogDao class and return the result. # 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