Skip to content

Commit

Permalink
feat: Reload every 20 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
WCY-dt committed Dec 17, 2024
1 parent a73af3e commit 1f840be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 11 additions & 15 deletions my-github-2024.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

app = Flask(__name__)

secret_key = os.urandom(24)
secret_key = "my-github-2024"
app.secret_key = secret_key

load_dotenv()
Expand All @@ -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
Expand Down Expand Up @@ -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)
6 changes: 5 additions & 1 deletion static/js/wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ function changeLoadingText() {
}

// Change the loading text every 6 seconds
setInterval(changeLoadingText, 6000);
setInterval(changeLoadingText, 6000);

setInterval(function () {
location.reload();
}, 20000);

0 comments on commit 1f840be

Please sign in to comment.