Skip to content

Commit 733bd57

Browse files
committed
Allow looking up institution by respondentID
This will allow us to include Institution information in A&D reports
1 parent bd9f5df commit 733bd57

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

query/src/main/scala/hmda/query/view/institutions/InstitutionView.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ object InstitutionView {
1919
val name = "institutions-view"
2020

2121
case class GetInstitutionById(institutionId: String) extends Command
22+
case class GetInstitutionByRespondentId(respondentId: String) extends Command
2223
case class GetInstitutionsById(ids: List[String]) extends Command
2324
case class FindInstitutionByPeriodAndDomain(domain: String) extends Command
2425

@@ -63,6 +64,12 @@ class InstitutionView extends HmdaPersistentActor {
6364
val institution = state.institutions.find(i => i.id == institutionId).getOrElse(Institution.empty)
6465
sender() ! institution
6566

67+
case GetInstitutionByRespondentId(respondentId) =>
68+
val institution = state.institutions.find { i =>
69+
i.respondent.externalId.value == respondentId
70+
}.getOrElse(Institution.empty)
71+
sender() ! institution
72+
6673
case GetInstitutionsById(ids) =>
6774
val institutions = state.institutions.filter(i => ids.contains(i.id))
6875
sender() ! institutions

query/src/test/scala/hmda/query/view/institutions/InstitutionViewSpec.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class InstitutionViewSpec extends ActorSpec {
5656
probe.send(institutionQuery, GetProjectionActorRef)
5757
probe.expectMsgType[ActorRef]
5858
}
59+
60+
"return institution by respondentId" in {
61+
probe.send(institutionQuery, GetInstitutionByRespondentId(i1.respondent.externalId.value))
62+
probe.expectMsg(i1)
63+
}
5964
}
6065

6166
}

0 commit comments

Comments
 (0)