Permalink
Browse files

Rename db field ordinal to play_order

  • Loading branch information...
1 parent a679796 commit eec3991cef279bbb5f83893f0e43327ae1aa7d20 @mcbuddha mcbuddha committed Mar 7, 2013
Showing with 10 additions and 10 deletions.
  1. +7 −7 misc/migrate.py
  2. +1 −1 queries.py
  3. +2 −2 server.py
View
@@ -56,24 +56,24 @@ def open_db_get_cursor():
cursor.close()
# ✂--------
-query_add_ordinal = """
+query_add_play_order = """
begin transaction;
-alter table assets add ordinal integer default 0;
+alter table assets add play_order integer default 0;
commit;
"""
-def migrate_add_ordinal():
+def migrate_add_play_order():
with open_db_get_cursor() as (cursor, conn):
- col = 'ordinal'
+ col = 'play_order'
if test_column(col, cursor):
print 'Column (' + col + ') already present'
else:
print 'Adding new column (' + col + ')'
- cursor.executescript(query_add_ordinal)
+ cursor.executescript(query_add_play_order)
assets = read(cursor)
for asset in assets:
- asset.update({'ordinal': 0})
+ asset.update({'play_order': 0})
update(cursor, asset['asset_id'], asset)
conn.commit()
# ✂--------
@@ -191,7 +191,7 @@ def fix_supervisor():
migrate_drop_filename()
migrate_add_is_enabled_and_nocache()
migrate_make_asset_id_primary_key()
- migrate_add_ordinal()
+ migrate_add_play_order()
ensure_conf()
fix_supervisor()
print "Migration done."
View
@@ -4,7 +4,7 @@
exists_table = "SELECT name FROM sqlite_master WHERE type='table' AND name='assets'"
-read_all = lambda keys: 'select ' + comma(keys) + ' from assets order by ordinal'
+read_all = lambda keys: 'select ' + comma(keys) + ' from assets order by play_order'
read = lambda keys: 'select ' + comma(keys) + ' from assets where asset_id=?'
create = lambda keys: 'insert into assets (' + comma(keys) + ') values (' + comma(['?'] * len(keys)) + ')'
remove = 'delete from assets where asset_id=?'
View
@@ -247,8 +247,8 @@ def remove_asset(asset_id):
@api
def playlist_order():
"Receive a list of asset_ids in the order they should be in the playlist"
- for ordinal,asset_id in enumerate(request.POST.get('ids', '').split(',')):
- assets_helper.update(db_conn, asset_id, {'asset_id':asset_id, 'ordinal':ordinal})
+ for play_order,asset_id in enumerate(request.POST.get('ids', '').split(',')):
+ assets_helper.update(db_conn, asset_id, {'asset_id':asset_id, 'play_order':play_order})
################################
# Views

0 comments on commit eec3991

Please sign in to comment.