Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions file-proxy/src/main/scala/hmda/uli/api/http/ProxyHttpApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ private class ProxyHttpApi(log: Logger)(implicit ec: ExecutionContext, system: A
}
}
}
pathPrefix("passthrough" / "data-browser" / "maps" / Remaining) { (mapsUrl) =>
(extractUri & get) { uri =>
//println(uri)
val s3Key = s"data-browser/maps/$mapsUrl"
jsonStreamingS3Route(s3Key)
}
}
pathPrefix("passthrough" / "reports" / Remaining) { (reportsUrl) =>
(extractUri & get) { uri =>
//println(uri)
val s3Key = s"reports/$reportsUrl"
jsonStreamingS3Route(s3Key)
}
}
pathPrefix("passthrough" / Remaining) { (s3Url) =>
(extractUri & get) { uri =>
//println(uri)
streamingS3Route(s3Url)
}
}
}
}
}
Expand All @@ -144,6 +164,20 @@ private class ProxyHttpApi(log: Logger)(implicit ec: ExecutionContext, system: A
}
}

private def jsonStreamingS3Route(s3Key: String): Route = {
val fStream: Future[Source[ByteString, NotUsed]] = retrieveData(s3Key).flatMap {
case Some(stream) =>
Future(stream)
case None =>
Future(Source.empty)
}

onComplete(fStream){
case Success(stream) => complete(HttpEntity(ContentTypes.`application/json`, stream))
case Failure(error) => complete(StatusCodes.BadRequest)
}
}

private def checkYearAvailable(availableYears: Seq[String], year: String): Directive0 = {
Directive[Unit](route =>
if (availableYears.contains(year)) route(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private class ReportingHttpApi(config: Config)(implicit ec: ExecutionContext) ex
private val institutionRepository2022 = new InstitutionRepository(databaseConfig, "institutions2022")
private val institutionRepository2023 = new InstitutionRepository(databaseConfig, "institutions2023")
private val institutionRepository2024 = new InstitutionRepository(databaseConfig, "institutions2024")
private val institutionRepository2025 = new InstitutionRepository(databaseConfig, "institutions2025")


private val filerListRoute: Route = {
Expand Down Expand Up @@ -141,6 +142,20 @@ private class ReportingHttpApi(config: Config)(implicit ec: ExecutionContext) ex
)
.toSet
)
case 2025 =>
institutionRepository2025
.getFilteredFilers(bankFilterList)
.map(sheets =>
sheets
.map(instituionEntity =>
HmdaFiler(
instituionEntity.lei.toUpperCase,
instituionEntity.respondentName,
instituionEntity.activityYear.toString
)
)
.toSet
)
case _ => Future(Set(HmdaFiler("", "", "")))
}

Expand All @@ -163,6 +178,7 @@ private class ReportingHttpApi(config: Config)(implicit ec: ExecutionContext) ex
case 2022 => institutionRepository2022
case 2023 => institutionRepository2023
case 2024 => institutionRepository2024
case 2025 => institutionRepository2025



Expand Down