mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 18:03:12 +00:00
refactor: Update database.py to use pathlib for reading migration files among other changes
This commit is contained in:
parent
1993132f27
commit
82ffaf82d8
3 changed files with 17 additions and 21 deletions
|
@ -2,6 +2,7 @@ import mysql.connector
|
|||
from loguru import logger
|
||||
from mysql.connector import pooling
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
from lib.constants import CONST
|
||||
|
@ -81,9 +82,9 @@ def run_migrations():
|
|||
continue
|
||||
|
||||
# Read and execute migration file
|
||||
with open(os.path.join(migrations_dir, migration_file)) as f:
|
||||
migration_sql = f.read()
|
||||
|
||||
migration_sql = pathlib.Path(
|
||||
os.path.join(migrations_dir, migration_file),
|
||||
).read_text()
|
||||
try:
|
||||
# Split the migration file into individual statements
|
||||
statements = re.split(r";\s*$", migration_sql, flags=re.MULTILINE)
|
||||
|
|
|
@ -36,14 +36,13 @@ class BlackJackButtons(View):
|
|||
self.stop()
|
||||
|
||||
async def interaction_check(self, interaction) -> bool:
|
||||
if interaction.user != self.ctx.author:
|
||||
await interaction.response.send_message(
|
||||
"You can't use these buttons, they're someone else's!",
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if interaction.user == self.ctx.author:
|
||||
return True
|
||||
await interaction.response.send_message(
|
||||
"You can't use these buttons, they're someone else's!",
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
class ExchangeConfirmation(View):
|
||||
|
@ -69,11 +68,10 @@ class ExchangeConfirmation(View):
|
|||
self.stop()
|
||||
|
||||
async def interaction_check(self, interaction) -> bool:
|
||||
if interaction.user != self.ctx.author:
|
||||
await interaction.response.send_message(
|
||||
"You can't use these buttons, they're someone else's!",
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if interaction.user == self.ctx.author:
|
||||
return True
|
||||
await interaction.response.send_message(
|
||||
"You can't use these buttons, they're someone else's!",
|
||||
ephemeral=True,
|
||||
)
|
||||
return False
|
||||
|
|
|
@ -16,7 +16,4 @@ def seconds_until(hours, minutes):
|
|||
if future_exec < now:
|
||||
future_exec += datetime.timedelta(days=1)
|
||||
|
||||
# Calculate the time difference in seconds
|
||||
seconds_until_execution = (future_exec - now).total_seconds()
|
||||
|
||||
return seconds_until_execution
|
||||
return (future_exec - now).total_seconds()
|
||||
|
|
Loading…
Reference in a new issue