forked from rmcauley/rainwave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rw_devtool_update_searchable_names.py
36 lines (29 loc) · 1.24 KB
/
rw_devtool_update_searchable_names.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# Updates the "searchable names" fields in the database that are used for full-text searches
from libs import config
from libs import db
from libs import log
from rainwave.playlist_objects.song import make_searchable_string
config.load()
log.init()
db.connect()
for row in db.c.fetch_all("SELECT song_id, song_title FROM r4_songs"):
db.c.update(
"UPDATE r4_songs SET song_title_searchable = %s WHERE song_id = %s",
(make_searchable_string(row["song_title"]), row["song_id"]),
)
for row in db.c.fetch_all("SELECT album_id, album_name FROM r4_albums"):
db.c.update(
"UPDATE r4_albums SET album_name_searchable = %s WHERE album_id = %s",
(make_searchable_string(row["album_name"]), row["album_id"]),
)
for row in db.c.fetch_all("SELECT group_id, group_name FROM r4_groups"):
db.c.update(
"UPDATE r4_groups SET group_name_searchable = %s WHERE group_id = %s",
(make_searchable_string(row["group_name"]), row["group_id"]),
)
for row in db.c.fetch_all("SELECT artist_id, artist_name FROM r4_artists"):
db.c.update(
"UPDATE r4_artists SET artist_name_searchable = %s WHERE artist_id = %s",
(make_searchable_string(row["artist_name"]), row["artist_id"]),
)