Skip to content

Commit

Permalink
Change to hourly optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Jan 26, 2025
1 parent 71fee4f commit 1f797cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions rootfs/webapp/acarshub.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def scheduled_tasks():

schedule.every().hour.at(":05").do(acarshub_configuration.check_github_version)
schedule.every().hour.at(":01").do(send_version)
schedule.every().hour.at(":30").do(acarshub_helpers.acarshub_database.optimize_db)
schedule.every().minute.at(":30").do(
acarshub_helpers.acarshub_database.prune_database
)
Expand Down
16 changes: 16 additions & 0 deletions rootfs/webapp/acarshub_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,3 +1237,19 @@ def prune_database():
finally:
if session:
session.close()


def optimize_db():
try:
acarshub_logging.log("Optimizing database", "database")
session = db_session()
session.execute(
text("insert into messages_fts(messages_fts) values('optimize')")
)
acarshub_logging.log("Database optimized", "database")
session.commit()
except Exception as e:
acarshub_logging.acars_traceback(e, "database")
finally:
if session:
session.close()

0 comments on commit 1f797cd

Please sign in to comment.