Skip to content

Commit a58f70d

Browse files
authored
Merge pull request #5057 from cfpb/instituions_api-year-selector
Disassociate HMDA Dashboard from Time Guard Settings.
2 parents bfccd30 + 0f298c2 commit a58f70d

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

common/src/main/scala/hmda/api/http/directives/CreateFilingAuthorization.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,11 @@ object CreateFilingAuthorization {
2727
if (Filer.checkQuarterlyYear(rulesConfig)(year)) successful
2828
else complete((BadRequest, ErrorResponse(BadRequest.intValue, "The provided year is not available", path)))
2929
}
30+
31+
def isInstitutionsYearAllowed(allowed: Boolean)(successful: Route): Route = extractMatchedPath { path =>
32+
if (allowed) successful
33+
else complete((BadRequest, ErrorResponse(BadRequest.intValue, "The provided year is not available via the institutions api", path)))
34+
}
35+
36+
3037
}

institutions-api/src/main/scala/hmda/institution/api/http/InstitutionQueryHttpApi.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private class InstitutionQueryHttpApi(config: Config)(implicit ec: ExecutionCont
4646
private val institutionByIdPath =
4747
path("institutions" / Segment / "year" / IntNumber) { (lei, year) =>
4848
(extractUri & get) { uri =>
49-
isQuarterlyYearAllowed(year) {
49+
isInstitutionsYearAllowed(yearsAvailable.contains(year.toString)){
5050

5151
val defaultRepo = institutionRepositories(institutionConfig.getString("defaultYear"))
5252
val fInstitution = institutionRepositories.getOrElse(year.toString, defaultRepo).findById(lei)
@@ -72,7 +72,7 @@ private class InstitutionQueryHttpApi(config: Config)(implicit ec: ExecutionCont
7272
private val institutionByDomainPath =
7373
path("institutions" / "year" / IntNumber) { year =>
7474
(extractUri & get) { uri =>
75-
isFilingAllowed(year, None) {
75+
isInstitutionsYearAllowed(yearsAvailable.contains(year.toString)){
7676
parameter('domain.as[String]) { domain =>
7777
val f = findByEmail(domain, year.toString)
7878
completeInstitutionsFuture(f, uri)

institutions-api/src/main/scala/hmda/institution/query/InstitutionComponent.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ trait InstitutionComponent {
7575
.result
7676
)
7777

78-
def createSchema() = db.run(table.schema.create)
79-
def dropSchema() = db.run(table.schema.drop)
78+
def createSchema() = db.run(table.schema.createIfNotExists)
79+
def dropSchema() = db.run(table.schema.dropIfExists)
8080
}
8181

8282
val institutionConfig: Config = ConfigFactory.load().getConfig("hmda.institution")

institutions-api/src/test/resources/application-createschema.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ cassandra-snapshot-store {
4444
hmda {
4545
institution {
4646
createSchema = false
47+
yearsAvailable = "2018,2019,2020,2021,2022"
48+
defaultYear = "2022"
4749
}
4850

4951
rules {

0 commit comments

Comments
 (0)