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:
Jonathan Bernard
2017-02-11 21:23:17 -06:00
parent 200b69b960
commit a6a68a5320
12 changed files with 89 additions and 70 deletions

View File

@ -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(

View File

@ -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" }
}