considering lazy loading for non-critical loc
This commit is contained in:
parent
de0368c20f
commit
1393b80970
|
@ -3,7 +3,7 @@ import subprocess
|
|||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
SHA1 = subprocess.getoutput("git rev-parse HEAD")
|
||||
SHA1 = lambda: subprocess.getoutput("git rev-parse HEAD")
|
||||
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
|
||||
@classmethod
|
||||
def create(cls, email, name, password=None, **kwargs):
|
||||
user: User = super(User, cls).create(email=email, name=name, **kwargs)
|
||||
user = super(User, cls).create(email=email, name=name, **kwargs)
|
||||
|
||||
if not password:
|
||||
# set a random password
|
||||
|
|
|
@ -4,7 +4,7 @@ from app.monitor.base import monitor_bp
|
|||
|
||||
@monitor_bp.route("/git")
|
||||
def git_sha1():
|
||||
return SHA1
|
||||
return SHA1()
|
||||
|
||||
|
||||
@monitor_bp.route("/exception")
|
||||
|
|
11
app/utils.py
11
app/utils.py
|
@ -7,19 +7,20 @@ from unidecode import unidecode
|
|||
from .config import WORDS_FILE_PATH
|
||||
from .log import LOG
|
||||
|
||||
with open(WORDS_FILE_PATH) as f:
|
||||
LOG.d("load words file: %s", WORDS_FILE_PATH)
|
||||
_words = f.read().split()
|
||||
def _word():
|
||||
with open(WORDS_FILE_PATH) as f:
|
||||
LOG.d("load words file: %s", WORDS_FILE_PATH)
|
||||
return f.read().split()
|
||||
|
||||
|
||||
def random_word():
|
||||
return random.choice(_words)
|
||||
return random.choice(_word())
|
||||
|
||||
|
||||
def random_words():
|
||||
"""Generate a random words. Used to generate user-facing string, for ex email addresses"""
|
||||
nb_words = random.randint(2, 3)
|
||||
return "_".join([random.choice(_words) for i in range(nb_words)])
|
||||
return "_".join([random.choice(_word()) for _ in range(nb_words)])
|
||||
|
||||
|
||||
def random_string(length=10):
|
||||
|
|
Loading…
Reference in New Issue