-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analytics duplication refactor #4920
base: master
Are you sure you want to change the base?
Changes from 1 commit
385d662
c883956
07eb747
7cb303e
3fcad82
e3a3ea4
1f851b7
85b9932
c41c260
64fd69c
fa870aa
2f59941
eba19f0
edb6c1e
4dd0be3
31eca7a
0b8d50b
db184bb
efa74b0
de39641
b267632
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,85 +317,12 @@ object HmdaAnalyticsApp extends App with TransmittalSheetComponent with LarCompo | |
for { | ||
insertorupdate <- submissionId.period match { | ||
case Period(2018, None) => YearlyLarRepositoryWrapper("2018").getLarRepository.insert(LarConverter2018(lar)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2018 has a special lar converter so we're keeping this here |
||
case Period(2019, None) => | ||
YearlyLarRepositoryWrapper("2019").getLarRepository.insert( | ||
LarConverter(lar, 2019) | ||
) | ||
case Period(2020, Some("Q1")) => | ||
QuarterlyLarRepositoryWrapper("2020", "Q1").getLarRepository.insert( | ||
LarConverter(lar = lar, 2020, isQuarterly = true) | ||
) | ||
case Period(2020, Some("Q2")) => | ||
QuarterlyLarRepositoryWrapper("2020", "Q2").getLarRepository.insert( | ||
LarConverter(lar = lar, 2020, isQuarterly = true) | ||
) | ||
case Period(2020, Some("Q3")) => | ||
QuarterlyLarRepositoryWrapper("2020", "Q3").getLarRepository.insert( | ||
LarConverter(lar = lar, 2020, isQuarterly = true) | ||
) | ||
case Period(2020, None) => | ||
YearlyLarRepositoryWrapper("2020").getLarRepository.insert( | ||
LarConverter(lar = lar, 2020) | ||
) | ||
case Period(2021, None) => | ||
YearlyLarRepositoryWrapper("2021").getLarRepository.insert( | ||
LarConverter(lar = lar, 2021) | ||
) | ||
case Period(2022, None) => | ||
YearlyLarRepositoryWrapper("2022").getLarRepository.insert( | ||
LarConverter(lar = lar, 2022) | ||
) | ||
case Period(2023, None) => | ||
YearlyLarRepositoryWrapper("2023").getLarRepository.insert( | ||
LarConverter(lar = lar, 2023) | ||
) | ||
case Period(2021, Some("Q1")) => | ||
QuarterlyLarRepositoryWrapper("2021", "Q1").getLarRepository.insert( | ||
LarConverter(lar = lar, 2021, isQuarterly = true) | ||
) | ||
case Period(2021, Some("Q2")) => | ||
QuarterlyLarRepositoryWrapper("2021", "Q2").getLarRepository.insert( | ||
LarConverter(lar = lar, 2021, isQuarterly = true) | ||
) | ||
case Period(2021, Some("Q3")) => | ||
QuarterlyLarRepositoryWrapper("2021", "Q3").getLarRepository.insert( | ||
LarConverter(lar = lar, 2021, isQuarterly = true) | ||
) | ||
case Period(2022, Some("Q1")) => | ||
QuarterlyLarRepositoryWrapper("2022", "Q1").getLarRepository.insert( | ||
LarConverter(lar = lar, 2022, isQuarterly = true) | ||
) | ||
case Period(2022, Some("Q2")) => | ||
QuarterlyLarRepositoryWrapper("2022", "Q2").getLarRepository.insert( | ||
LarConverter(lar = lar, 2022, isQuarterly = true) | ||
) | ||
case Period(2022, Some("Q3")) => | ||
QuarterlyLarRepositoryWrapper("2022", "Q3").getLarRepository.insert( | ||
LarConverter(lar = lar, 2022, isQuarterly = true) | ||
) | ||
case Period(2023, Some("Q1")) => | ||
QuarterlyLarRepositoryWrapper("2023", "Q1").getLarRepository.insert( | ||
LarConverter(lar = lar, 2023, isQuarterly = true) | ||
) | ||
case Period(2023, Some("Q2")) => | ||
QuarterlyLarRepositoryWrapper("2023", "Q2").getLarRepository.insert( | ||
LarConverter(lar = lar, 2023, isQuarterly = true) | ||
) | ||
case Period(2023, Some("Q3")) => | ||
QuarterlyLarRepositoryWrapper("2023", "Q3").getLarRepository.insert( | ||
LarConverter(lar = lar, 2023, isQuarterly = true) | ||
) | ||
case Period(2024, Some("Q1")) => | ||
QuarterlyLarRepositoryWrapper("2024", "Q1").getLarRepository.insert( | ||
LarConverter(lar = lar, 2024, isQuarterly = true) | ||
) | ||
case Period(2024, Some("Q2")) => | ||
QuarterlyLarRepositoryWrapper("2024", "Q2").getLarRepository.insert( | ||
LarConverter(lar = lar, 2024, isQuarterly = true) | ||
) | ||
case Period(2024, Some("Q3")) => | ||
QuarterlyLarRepositoryWrapper("2024", "Q3").getLarRepository.insert( | ||
LarConverter(lar = lar, 2024, isQuarterly = true) | ||
case Period(submissionId.period.year, None) => YearlyLarRepositoryWrapper(submissionId.period.year.toString).getLarRepository.insert( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this works, on another unit test ticket I'm going to refactor this a bit to demonstrate that. I think we should stick to making this depend on the submissionId for now since this line is a part of reading from that. |
||
LarConverter(lar, submissionId.period.year) | ||
) | ||
case Period(submissionId.period.year, Some(submissionId.period.quarter)) => | ||
QuarterlyLarRepositoryWrapper(submissionId.period.year.toString, submissionId.period.quarter).getLarRepository.insert( | ||
LarConverter(lar = lar, submissionId.period.year, isQuarterly = true) | ||
) | ||
case _ => { | ||
log.error(s"Unable to discern period from $submissionId to insert LAR rows.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we replace this very long match statement with a map? And maybe do the same for the other match statements here? It would cut down on a ton of lines of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm could you clarify a bit what you were thinking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, map isn't the right thing here. Not sure what I was thinking yesterday.
What I meant is we can simplify this to 2-3 cases:
case Period(year, None) =>
andcase Period(year, Some(quarter)) =>
(and keep the finalcase _ =>
case). Using a variable for the year and quarter will get rid of a ton of these match cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah let's do that, will take some time to update