From 1f840be7ecccc15260f7ae3636a051b5ea0ebe3d Mon Sep 17 00:00:00 2001 From: WCY-dt <834421194@qq.com> Date: Wed, 18 Dec 2024 01:44:08 +0800 Subject: [PATCH] feat: Reload every 20 seconds --- my-github-2024.py | 26 +++++++++++--------------- static/js/wait.js | 6 +++++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/my-github-2024.py b/my-github-2024.py index c7cf16e..0221d14 100644 --- a/my-github-2024.py +++ b/my-github-2024.py @@ -25,7 +25,7 @@ app = Flask(__name__) -secret_key = os.urandom(24) +secret_key = "my-github-2024" app.secret_key = secret_key load_dotenv() @@ -49,6 +49,16 @@ class UserContext(db.Model): with app.app_context(): db.create_all() + missing_users = ( + db.session.query(RequestedUser) + .outerjoin(UserContext, RequestedUser.username == UserContext.username) + .filter(UserContext.username == None) + .all() + ) + for user in missing_users: + logging.info(f"Missing user: {user.username}") + db.session.query(RequestedUser).filter_by(username=user.username).delete() + db.session.commit() @app.before_request @@ -181,20 +191,6 @@ def static_files(filename): return send_from_directory("static", filename) -def delete_missing_users(): - with app.app_context(): - missing_users = ( - db.session.query(RequestedUser) - .outerjoin(UserContext, RequestedUser.username == UserContext.username) - .filter(UserContext.username == None) - .all() - ) - for user in missing_users: - logging.info(f"Missing user: {user.username}") - db.session.query(RequestedUser).filter_by(username=user.username).delete() - db.session.commit() - if __name__ == "__main__": - delete_missing_users() app.run(host="0.0.0.0", port=5000) diff --git a/static/js/wait.js b/static/js/wait.js index d5009c6..276682f 100644 --- a/static/js/wait.js +++ b/static/js/wait.js @@ -11,4 +11,8 @@ function changeLoadingText() { } // Change the loading text every 6 seconds -setInterval(changeLoadingText, 6000); \ No newline at end of file +setInterval(changeLoadingText, 6000); + +setInterval(function () { + location.reload(); +}, 20000); \ No newline at end of file