Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ class ModifiedLarRepository(databaseConfig: DatabaseConfig[JdbcProfile]) {
db.run(
sqlu"DELETE FROM #${fetchYearTable(submissionId.period.year.toInt)} WHERE UPPER(lei) = ${submissionId.lei.toUpperCase} and filing_year = ${submissionId.period.year.toInt}"
)

/**
* Deletes entries in the Modified LAR table by their Submission ID
* This is to account for the change from S303 to Q303
* @param submissionId
* @return the number of rows removed
*/
def deleteBySubmissionID(submissionId: SubmissionId): Future[Int] = {
val likeStatement = s"${submissionId.lei}-%"
db.run(
sqlu"""DELETE FROM #${fetchYearTable(period.toInt)} WHERE submission_id LIKE $likeStatement"""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to just delete by the lei only? since the mlar tables themselves are already period specific?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
}

/**
* Inserts Modified Loan Application Register data that has been enhanced with Census information via the tract map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ object ModifiedLarPublisher {
.withAttributes(S3Attributes.settings(s3Settings))

def removeLei: Future[Int] =
modifiedLarRepo.deleteByLei(submissionId)
modifiedLarRepo.deleteBySubmissionID(submissionId)

val mlarSource: Source[ModifiedLoanApplicationRegister, NotUsed] =
readRawData(system)(submissionId)
Expand Down Expand Up @@ -175,6 +175,7 @@ object ModifiedLarPublisher {

val finalResult: Future[Unit] = for {
_ <- if (regenerateMlar)
removeLei
graphWithS3AndPG.run()
else if (isGenerateBothS3Files) {
removeLei
Expand Down
Loading