-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update late filers to work with paramter
- Loading branch information
1 parent
a6d25b6
commit 143c95a
Showing
10 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
hmda-dashboard/src/main/scala/hmda/dashboard/api/DashboardDirectives.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package hmda.dashboard.api | ||
|
||
import akka.http.scaladsl.model.StatusCodes.BadRequest | ||
import akka.http.scaladsl.server.Directives._ | ||
import akka.http.scaladsl.server._ | ||
import akka.http.scaladsl.server.directives.RouteDirectives.complete | ||
import hmda.dashboard.Settings | ||
import hmda.dashboard.models._ | ||
|
||
|
||
trait DashboardDirectives extends Settings { | ||
|
||
private def extractDatetime: Directive1[String] = | ||
parameters("late_date" ).flatMap { | ||
case "" => | ||
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport._ | ||
complete((BadRequest, "must provide late_date")) | ||
|
||
case x => provide(x) | ||
} | ||
|
||
def extractNationwideMandatoryYears(innerRoute: String => Route): Route = | ||
(extractDatetime) { (datetime) => | ||
if (datetime.nonEmpty) | ||
innerRoute(datetime) | ||
else { | ||
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport._ | ||
complete((BadRequest, ProvideDatetime())) | ||
} | ||
} | ||
|
||
} | ||
|
||
object DashboardDirectives extends DashboardDirectives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
hmda-dashboard/src/main/scala/hmda/dashboard/models/ErrorResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package hmda.dashboard.models | ||
|
||
import io.circe.Encoder | ||
import io.circe.generic.semiauto._ | ||
|
||
// $COVERAGE-OFF$ | ||
sealed trait ErrorResponse { | ||
def errorType: String | ||
def message: String | ||
} | ||
|
||
object ProvideDatetime { | ||
implicit val encoder: Encoder[ProvideDatetime] = deriveEncoder[ProvideDatetime] | ||
} | ||
final case class ProvideDatetime(errorType: String = "Bad Format", message: String = "Must provide date time in ##/##/#### ##:##:## format") extends ErrorResponse | ||
|
||
// $COVERAGE-ON$ |
20 changes: 20 additions & 0 deletions
20
hmda-dashboard/src/main/scala/hmda/dashboard/models/LateFilers.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package hmda.dashboard.models | ||
|
||
import io.circe.Codec | ||
import slick.jdbc.GetResult | ||
|
||
case class LateFilers( | ||
agency: Int, | ||
institution_name: String, | ||
lei: String, | ||
total_lines: String, | ||
sign_date: String, | ||
sub_id: String | ||
) | ||
|
||
object LateFilers { | ||
implicit val getResults: GetResult[LateFilers] = GetResult(r => LateFilers(r.<<,r.<<,r.<<,r.<<,r.<<,r.<<)) | ||
|
||
implicit val codec: Codec[LateFilers] = | ||
Codec.forProduct6("Agency","Institution Name","LEI","Total Lars","Sign Date (EST)","Submission ID")(LateFilers.apply)(f => (f.agency,f.institution_name,f.lei,f.total_lines,f.sign_date,f.sub_id)) | ||
} |
20 changes: 20 additions & 0 deletions
20
hmda-dashboard/src/main/scala/hmda/dashboard/models/LateFilersAggregationResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package hmda.dashboard.models | ||
|
||
import io.circe.{Decoder, Encoder, HCursor} | ||
|
||
case class LateFilersAggregationResponse(aggregations: Seq[LateFilers]) | ||
|
||
object LateFilersAggregationResponse { | ||
private object constants { | ||
val Results = "results" | ||
} | ||
|
||
implicit val encoder: Encoder[LateFilersAggregationResponse] = | ||
Encoder.forProduct1(constants.Results)(aggR => | ||
aggR.aggregations) | ||
|
||
implicit val decoder: Decoder[LateFilersAggregationResponse] = (c: HCursor) => | ||
for { | ||
a <- c.downField(constants.Results).as[Seq[LateFilers]] | ||
} yield LateFilersAggregationResponse(a) | ||
} |
6 changes: 6 additions & 0 deletions
6
hmda-dashboard/src/main/scala/hmda/dashboard/models/QueryField.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package hmda.dashboard.models | ||
|
||
case class QueryField(name: String, | ||
value: Seq[String]) | ||
|
||
case class QueryFields(name: String, value: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters