Skip to content

Commit

Permalink
Merge pull request #1006 from schbetsy/sort-subs
Browse files Browse the repository at this point in the history
Sort submissions by descending sequenceNumber
  • Loading branch information
Nick Grippin authored Jun 13, 2017
2 parents 84cae0a + ee178e0 commit 29021da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SubmissionPersistence(institutionId: String, period: String) extends HmdaP
sender() ! latest

case GetState =>
sender() ! state.submissions
sender() ! state.submissions.sortWith(_.id.sequenceNumber > _.id.sequenceNumber)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ class SubmissionPersistenceSpec extends ActorSpec {
probe.send(submissionsActor, UpdateSubmissionStatus(id, Created))
probe.expectMsg(None)
}

"return list of submissions in order of descending sequence number" in {
probe.send(submissionsActor, GetState)
val subs = probe.expectMsgType[List[Submission]]
subs.head.id.sequenceNumber mustBe 3
subs(1).id.sequenceNumber mustBe 2
subs(2).id.sequenceNumber mustBe 1
}
}

}

0 comments on commit 29021da

Please sign in to comment.