diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..b255d30
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ mariadb
+ true
+ org.mariadb.jdbc.Driver
+ jdbc:mariadb://localhost:3306/musicmuster_dev
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
index 105ce2d..dd4c951 100644
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -1,5 +1,6 @@
+
diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml
new file mode 100644
index 0000000..63772a3
--- /dev/null
+++ b/.idea/sqldialects.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/alembic.ini b/alembic.ini
index 569ba00..d744355 100644
--- a/alembic.ini
+++ b/alembic.ini
@@ -39,8 +39,7 @@ prepend_sys_path = .
# are written from script.py.mako
# output_encoding = utf-8
-sqlalchemy.url = mysql+mysqldb://songdb:songdb@localhost/musicmuster
-
+sqlalchemy.url = mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_dev
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
diff --git a/app/model.py b/app/model.py
index b16bc25..fe0e82d 100644
--- a/app/model.py
+++ b/app/model.py
@@ -38,6 +38,36 @@ Session = sessionmaker(bind=engine)
# Database classes
+class NoteColours(Base):
+ __tablename__ = 'notecolours'
+
+ id = Column(Integer, primary_key=True, autoincrement=True)
+ substring = Column(String(256), index=False)
+ hexcolour = Column(String(6), index=False)
+ enabled = Column(Boolean, default=True, index=False)
+ is_regex = Column(Boolean, default=False, index=False)
+ is_casesensitive = Column(Boolean, default=False, index=False)
+
+ def __repr__(self):
+ return (
+ f""
+ )
+
+ @staticmethod
+ def get_colour(session, text):
+ """
+ Parse text and return colour string if match, else None
+
+ Currently ignore is_regex and is_casesensitive
+ """
+
+ for rec in session.query(NoteColours).all():
+ if rec.substring in text:
+ return '#' + rec.hexcolour
+
+ return None
+
+
class Notes(Base):
__tablename__ = 'notes'
@@ -115,7 +145,7 @@ class Playdates(Base):
last_played = session.query(Playdates.lastplayed).filter(
(Playdates.track_id == track_id)
- ).order_by(Playdates.lastplayed.desc()).first()
+ ).order_by(Playdates.lastplayed.desc()).first()
if last_played:
return last_played[0]
else:
@@ -221,11 +251,11 @@ class Playlists(Base):
return (
session.query(Playlists)
- .filter(
+ .filter(
(Playlists.loaded == False) | # noqa E712
(Playlists.loaded == None)
)
- .order_by(Playlists.last_used.desc())
+ .order_by(Playlists.last_used.desc())
).all()
@staticmethod
@@ -242,8 +272,8 @@ class Playlists(Base):
return (
session.query(Playlists)
- .filter(Playlists.loaded == True) # noqa E712
- .order_by(Playlists.last_used.desc())
+ .filter(Playlists.loaded == True) # noqa E712
+ .order_by(Playlists.last_used.desc())
).all()
def get_notes(self):
@@ -253,8 +283,8 @@ class Playlists(Base):
def get_playlist(session, playlist_id):
return (
session.query(Playlists)
- .filter(
- Playlists.id == playlist_id # noqa E712
+ .filter(
+ Playlists.id == playlist_id # noqa E712
)
).one()
@@ -320,7 +350,7 @@ class PlaylistTracks(Base):
f"to_playlist_id={to_playlist_id})"
)
max_row = session.query(func.max(PlaylistTracks.row)).filter(
- PlaylistTracks.playlist_id == to_playlist_id).scalar()
+ PlaylistTracks.playlist_id == to_playlist_id).scalar()
if max_row is None:
# Destination playlist is empty; use row 0
new_row = 0
@@ -454,6 +484,7 @@ class Tracks(Base):
f"