Skip to content

Commit

Permalink
Merge pull request #4214 from cfpb/quarter-late-filer-cutoff
Browse files Browse the repository at this point in the history
allow for optional cutoff date for quarter late filers
  • Loading branch information
PatrickGoRaft authored Oct 12, 2021
2 parents f795896 + 8647d88 commit 1eef563
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,14 @@ private class HmdaDashboardHttpApi(log: Logger, config: Config)(implicit val ec:
}
} ~
path("quarter_late_filers" / Segment) { (period) =>
log.info(s"Fetching late filers for period=$period")
complete {
query
.fetchLateFilersByQuarter(period)
.map(aggs => LateFilersAggregationResponse(aggs))
.runToFuture
parameters("late_date".optional) { optionalField =>
log.info(s"Fetching quarter late filers for period=$period with optionalField=$optionalField")
complete {
query
.fetchLateFilersByQuarter(period, optionalField.getOrElse(""))
.map(LateFilersAggregationResponse(_))
.runToFuture
}
}
} ~
path("voluntary_filers" / Segment) { (period) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,11 @@ class PostgresRepository (config: DatabaseConfig[JdbcProfile],bankFilterList: Ar
Task.deferFuture(db.run(query)).guarantee(Task.shift)
}

def fetchLateFilersByQuarter(period: String): Task[Seq[LateFilers]] = {
def fetchLateFilersByQuarter(period: String, cutoff: String): Task[Seq[LateFilers]] = {
val tsTable = tsTableSelector(period)
val subHistMview = "submission_hist_mview"
val (year, quarter, lateDate) = getQuarterLateFilersInfo(period)
val (year, quarter, quarterLateDate) = getQuarterLateFilersInfo(period)
val lateDate = if (cutoff.nonEmpty) cutoff else quarterLateDate
val query = sql"""
select * from (
select ts.agency, ts.institution_name, sh.lei, ts.total_lines, sh.sign_date_east :: date, sh.submission_id, rank() over(partition by sh.lei order by sh.sign_date_east asc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class DashboardQueryService (repo: PostgresRepository) extends QueryService{
override def fetchLateFilers(period: String, late: String): Task[Seq[LateFilers]] =
repo.fetchLateFilers(period, late)

override def fetchLateFilersByQuarter(period: String): Task[Seq[LateFilers]] =
repo.fetchLateFilersByQuarter(period)
override def fetchLateFilersByQuarter(period: String, cutoff: String): Task[Seq[LateFilers]] =
repo.fetchLateFilersByQuarter(period, cutoff)

override def fetchVoluntaryFilers(period: String): Task[Seq[VoluntaryFilers]] =
repo.fetchVoluntaryFilers(period)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ trait QueryService {
def fetchFilersCountOpenEndOriginationsByAgencyGraterOrEqual(period: String, x: Int) : Task[Seq[FilersCountOpenEndOriginationsByAgencyGraterOrEqual]]
def fetchTopInstitutionsCountOpenEndCredit(period: String, x: Int) : Task[Seq[TopInstitutionsCountOpenEndCredit]]
def fetchLateFilers(period: String, late: String) : Task[Seq[LateFilers]]
def fetchLateFilersByQuarter(period: String) : Task[Seq[LateFilers]]
def fetchLateFilersByQuarter(period: String, cutoff: String) : Task[Seq[LateFilers]]
def fetchVoluntaryFilers(period: String) : Task[Seq[VoluntaryFilers]]
}

0 comments on commit 1eef563

Please sign in to comment.