Add song rank in performance. Use DbMigrate in tests.
* Add the song order in a service using `performances.rank` to indicate the relative position of each song within the service. The service page now respects this ranking. * Update the tests to use DB Migrate to manage the database transitions.
This commit is contained in:
@ -152,10 +152,10 @@ public class NLSongsDB {
|
||||
public Performance create(Performance perf) {
|
||||
// TODO: handle constraint violation (same service and song ids)
|
||||
sql.executeInsert(
|
||||
"INSERT INTO performances (service_id, song_id, pianist, " +
|
||||
"INSERT INTO performances (service_id, song_id, rank, pianist, " +
|
||||
"organist, bassist, drummer, guitarist, leader) VALUES " +
|
||||
"(?, ?, ?, ?, ?, ?, ?, ?)", [perf.serviceId, perf.songId,
|
||||
perf.pianist, perf.organist, perf.bassist, perf.drummer,
|
||||
perf.rank, perf.pianist, perf.organist, perf.bassist, perf.drummer,
|
||||
perf.guitarist, perf.leader])
|
||||
return perf }
|
||||
|
||||
@ -163,10 +163,11 @@ public class NLSongsDB {
|
||||
// TODO: handle constraint violation (same service and song ids)
|
||||
return sql.executeUpdate(
|
||||
"UPDATE performances SET pianist = ?, organist = ?, " +
|
||||
"bassist = ?, drummer = ?, guitarist = ?, leader = ? " +
|
||||
"WHERE service_id = ? AND song_id = ?",
|
||||
"bassist = ?, drummer = ?, guitarist = ?, leader = ?, " +
|
||||
"rank = ? WHERE service_id = ? AND song_id = ?",
|
||||
[perf.pianist, perf.organist, perf.bassist, perf.drummer,
|
||||
perf.guitarist, perf.leader, perf.serviceId, perf.songId]) }
|
||||
perf.guitarist, perf.leader, perf.rank, perf.serviceId,
|
||||
perf.songId]) }
|
||||
|
||||
public int delete(Performance perf) {
|
||||
sql.execute(
|
||||
|
@ -4,6 +4,7 @@ public class Performance implements Serializable {
|
||||
|
||||
int serviceId
|
||||
int songId
|
||||
int rank
|
||||
String pianist
|
||||
String organist
|
||||
String bassist
|
||||
@ -19,6 +20,7 @@ public class Performance implements Serializable {
|
||||
|
||||
return (this.serviceId == that.serviceId &&
|
||||
this.songId == that.songId &&
|
||||
this.rank == that.rank &&
|
||||
this.pianist == that.pianist &&
|
||||
this.organist == that.organist &&
|
||||
this.bassist == that.bassist &&
|
||||
@ -27,5 +29,5 @@ public class Performance implements Serializable {
|
||||
this.leader == that.leader) }
|
||||
|
||||
@Override String toString() {
|
||||
return "($serviceId, $songId): $leader - $pianist" }
|
||||
return "($serviceId, $songId)-$rank: $leader - $pianist" }
|
||||
}
|
||||
|
Reference in New Issue
Block a user