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

Update project

parent f7ead397
......@@ -12,6 +12,6 @@
from .config import ConsulConfig, LocalConfig
from .error import ConfigKeyError
from .flask_consul import FlaskConsulService
from .flask_elasticsearch import FlaskElasticsearch
from .flask_loguru import FlaskLoguru
from .flask_consul import FlaskConsulService
......@@ -13,7 +13,7 @@
import atexit
import consul
from flask import current_app, Flask
from flask import Flask
from application.libs.helper import ConfigHelper
from application.libs.helper import EnvVarHelper
......
......@@ -10,27 +10,48 @@
# @Description :
"""
# Import built-in modules
import datetime
# Import custom modules
from application.dao import LogDao
from application.extensions.init_sqlalchemy import db
def task():
"""
Some Tasks.
Execute some tasks.
:return: None
This function defines a task to parse logs between two specific datetime points.
The task uses the application's database context and configurations for the Elasticsearch index
and an additional database.
It uses the `parse` method from `LogDao` to process the logs.
Note: The start and end dates are hardcoded in this example.
Returns:
None
"""
# end_stamp = datetime.datetime.now()
# start_stamp = end_stamp - datetime.timedelta(days=1)
# start = start_stamp.strftime('%Y-%m-%d %H:%M:%S')
# end = end_stamp.strftime('%Y-%m-%d %H:%M:%S')
start = "2021-11-08 00:00:00"
end = "2021-11-09 00:00:00"
# You can uncomment the following lines to use the current date and time and the previous day's date and time
end_stamp = datetime.datetime.now()
start_stamp = end_stamp - datetime.timedelta(days=1)
start = start_stamp.strftime('%Y-%m-%d %H:%M:%S')
end = end_stamp.strftime('%Y-%m-%d %H:%M:%S')
# Here the start and end dates are hardcoded
# start = "2021-11-08 00:00:00"
# end = "2021-11-09 00:00:00"
# Use the application's database context
with db.app.app_context():
# Get the Elasticsearch index from the application's configuration
index = db.app.config.Elasticsearch.Index
# Get the ExtraDB configuration from the application's configuration
cfg = db.app.config.ExtraDB
# Create a dictionary of options for the additional database
options = {
"host": cfg.Host,
"user": cfg.User,
......@@ -38,6 +59,10 @@ def task():
"database": cfg.DB,
"port": cfg.Port,
}
# Get the SQL query from the ExtraDB configuration
sql = cfg.Sql
# Call the parse method from LogDao with the necessary parameters
LogDao.parse(start, end, 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