Skip to content
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

Feature/1111 tanf section 4 #2657

Merged
merged 211 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 197 commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
3a36b7a
- ADding t2 schema
elipe17 Apr 10, 2023
c02798c
- small fixes to naming
elipe17 Apr 11, 2023
b4abd83
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Apr 18, 2023
e29eb2d
- Added new doc for T2
elipe17 Apr 19, 2023
1c5f1a1
- Added T3 schema defs
elipe17 Apr 20, 2023
af43fad
- Fixing most lint errors
elipe17 Apr 20, 2023
92660ff
- Updated T3 to multirow record
elipe17 Apr 24, 2023
9d18c7f
- Added unit test and data files
elipe17 Apr 24, 2023
44d2aa6
- Updating var names to conform to DB max var name length
elipe17 Apr 24, 2023
a98f030
- Updating based on unit test failure
elipe17 Apr 24, 2023
6649865
- adding datafile
elipe17 Apr 25, 2023
b3e3478
- Adding unit tests for t2 and t3
elipe17 Apr 26, 2023
9a6a7f1
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Apr 26, 2023
55c01e5
- Fixed field types
elipe17 Apr 28, 2023
1455ae4
- Removing many migrations to consolodate into one migration
elipe17 Apr 28, 2023
8bae069
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 May 1, 2023
d921e15
Revert "- Removing many migrations to consolodate into one migration"
elipe17 May 1, 2023
1e4e27e
- Resolved test issues after merge
elipe17 May 1, 2023
8ec81b6
- Resolve lint errors
elipe17 May 1, 2023
bbed78a
Merge branch 'feature/1113-1-ssp-section-1-models' of https://github.…
elipe17 May 1, 2023
956e08f
Merge branch 'feature/1113-1-ssp-section-1-models' into 2424-ts1-parsing
elipe17 May 1, 2023
8524878
- Merged 1113.2
elipe17 May 2, 2023
262a0c6
Merge branch 'feature/1113-2-ssp-section-1-parsing' of https://github…
elipe17 May 2, 2023
d064aac
- Removed unnecessary file
elipe17 May 3, 2023
6b22441
- Rename model fields
elipe17 May 3, 2023
c00933e
- fixed spelling in test
elipe17 May 3, 2023
dcbe9a2
- Fixed lint errors
elipe17 May 3, 2023
28e126e
rm commented validators
jtimpe May 5, 2023
a778319
- Updated schema newlines to be consistent
elipe17 May 8, 2023
31d56a9
Merge branch 'develop' into feature/1113-2-ssp-section-1-parsing
ADPennington May 12, 2023
426d4c3
Merge branch 'feature/1113-2-ssp-section-1-parsing' of https://github…
elipe17 May 15, 2023
73e359c
- Updated field names
elipe17 May 15, 2023
c36a6b3
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 May 18, 2023
a5571d3
- consolodating migrations
elipe17 May 22, 2023
2126eb5
- Updated readme and backup script
elipe17 May 23, 2023
b44e913
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 May 24, 2023
919caf3
- Updated parse logic to batch create records
elipe17 May 24, 2023
0bb5ee4
- Fixed lint errors
elipe17 May 24, 2023
baed23e
- Batching record serialization
elipe17 May 25, 2023
b398af8
- Updated parse logic
elipe17 May 26, 2023
2b67871
- Adding big s1 datafile
elipe17 May 26, 2023
fc3bf73
- fixing lint errors
elipe17 May 26, 2023
4827b20
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 May 26, 2023
64b78b7
- Removing test to see if its causing weird failure
elipe17 May 30, 2023
879bf3a
- Updating based on comments
elipe17 May 30, 2023
48a825f
- fixing error in update method
elipe17 May 30, 2023
2be97db
- fixing error in update
elipe17 May 30, 2023
186a959
- Removed extraneous seek
elipe17 May 30, 2023
2854ce5
- updating ignore to ignore patch files
elipe17 May 30, 2023
4ee1827
- Made evaluate_trailer pure/immutable
elipe17 May 31, 2023
2bdd086
Revert "- Removing test to see if its causing weird failure"
elipe17 May 31, 2023
0d6c29e
- Use custom transactions while parsing
elipe17 Jun 1, 2023
c089a7c
- updated store logic to one liner
elipe17 Jun 1, 2023
4bc122b
- removed function
elipe17 Jun 1, 2023
c0f540c
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jun 5, 2023
1dbe194
- refactored multirecord schema to be a schema manager instead
elipe17 Jun 5, 2023
08decd6
- Name update for clarity
elipe17 Jun 5, 2023
3f0a7ec
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jun 21, 2023
83f8d2f
- Fix lint errors
elipe17 Jun 21, 2023
b3a6463
- Changing batch size to avoid crash in circi
elipe17 Jun 21, 2023
475ca29
- Updated based on review
elipe17 Jun 26, 2023
90ff554
- Updated based on review/OH
elipe17 Jun 26, 2023
62d4367
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jun 28, 2023
5fca243
- Updated view to show latest datafiles
elipe17 Jun 28, 2023
be89574
- Updated based on review comments
elipe17 Jun 29, 2023
1a71d14
- Updated based on feedback for preparse error handling
elipe17 Jul 5, 2023
a7109c3
- Updated search indices to have parent FK
elipe17 Jul 5, 2023
21a7006
- Fix lint errors
elipe17 Jul 5, 2023
4597d21
- Updated submission tests
elipe17 Jul 6, 2023
7892115
- fix lint errors
elipe17 Jul 6, 2023
0c2d57b
- removing frontend filtering
elipe17 Jul 6, 2023
35a6f24
- addding datafile to admin model
elipe17 Jul 6, 2023
0146a0f
Revert "- addding datafile to admin model"
elipe17 Jul 6, 2023
d354f71
- Fixed issue where datafile FK wasnt populating
elipe17 Jul 6, 2023
2807425
- Readding datafile back to admin view now that the error is resolved
elipe17 Jul 6, 2023
6c54528
- adding datafile back
elipe17 Jul 6, 2023
d1edc20
Revert "- Readding datafile back to admin view now that the error is …
elipe17 Jul 7, 2023
f75fbca
- Removed unnecessary fields
elipe17 Jul 7, 2023
764e212
- Updated document to include required fields
elipe17 Jul 7, 2023
cb5077c
- Moved datafile reference to avoid confusion
elipe17 Jul 10, 2023
2cfe62d
Merge branch 'develop' into 2486-parser-performance
ADPennington Jul 11, 2023
d0441b7
- Updating based on comments.
elipe17 Jul 14, 2023
3b69a8b
Merge branch '2579-latest-data' into 2486-parser-performance
elipe17 Jul 14, 2023
a251506
- Refactored parsing to avoid custom transactions by leveraging the F…
elipe17 Jul 14, 2023
b32c55e
- small optimization for the rollback
elipe17 Jul 17, 2023
822b98b
- Fix lint errors
elipe17 Jul 17, 2023
2817fa4
- Removing commented code
elipe17 Jul 17, 2023
42786b7
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jul 17, 2023
782a5f7
- Installing build essentials
elipe17 Jul 17, 2023
f8b23bc
Revert "- Installing build essentials"
elipe17 Jul 17, 2023
f529728
- adding setup tools and wheel
elipe17 Jul 17, 2023
aad782a
Revert "- adding setup tools and wheel"
elipe17 Jul 17, 2023
b263c12
- Updating dependencies to get around pep issue
elipe17 Jul 18, 2023
fdb2fe1
- Pin factoryboy
elipe17 Jul 18, 2023
63f6c97
Merge branch '2579-latest-data' into 2486-parser-performance
elipe17 Jul 18, 2023
2c32869
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jul 18, 2023
47b7c50
- Updating manifest
elipe17 Jul 19, 2023
1784339
- Added EncryptedField class
elipe17 Jul 21, 2023
205d455
- Fix lint errors
elipe17 Jul 21, 2023
685e2d1
- Added decryption for ssp
elipe17 Jul 21, 2023
2247117
- Making the encrypted check stronger
elipe17 Jul 21, 2023
c24af6d
- Added section two models, schemas, and an initial test
elipe17 Jul 24, 2023
62cc8dc
- Allowing fields to be nullable
elipe17 Jul 24, 2023
bb40fe8
- add missing field
elipe17 Jul 24, 2023
0cb5a9d
- Consolodating migrations
elipe17 Jul 24, 2023
85fd8e0
- Consolodate migration
elipe17 Jul 24, 2023
f0c5687
Merge branch '332-ssn-encryption' into 1109-tanf-section2
elipe17 Jul 24, 2023
677b065
- Added encrypted field
elipe17 Jul 24, 2023
fe8d630
- Refactored fields and rowschema into seperate files
elipe17 Jul 24, 2023
ab58a3a
- fix lint errors
elipe17 Jul 24, 2023
5064b04
Merge branch '332-ssn-encryption' into 1109-tanf-section2
elipe17 Jul 24, 2023
4b7e4a4
- Fixed file spacing
elipe17 Jul 24, 2023
fb6f580
- fix imports
elipe17 Jul 24, 2023
d15aec0
- Fix import error
elipe17 Jul 24, 2023
224b264
- Fix failing test
elipe17 Jul 25, 2023
dd7089b
- Revert erroneous change
elipe17 Jul 26, 2023
0896b63
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jul 26, 2023
5f5214b
- Updating item numbers
elipe17 Jul 26, 2023
f0241f7
- Fixed item numbers
elipe17 Jul 26, 2023
df852a9
- Updating to accomodate item number as string
elipe17 Jul 26, 2023
8b57615
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jul 26, 2023
0dd6b15
- Removed erroneous update that was causing error
elipe17 Jul 26, 2023
69e2ab1
- White space error
elipe17 Jul 26, 2023
1818a0f
- Resolved error
elipe17 Jul 26, 2023
a0bd682
Merge branch '332-ssn-encryption' into 1109-tanf-section2
elipe17 Jul 26, 2023
a63e56e
- Fixing test
elipe17 Jul 26, 2023
329010c
- fix lint errors
elipe17 Jul 26, 2023
391a1c9
- Added field validators for T4/T5
elipe17 Jul 27, 2023
b7933ba
- Added cat3 validators
elipe17 Jul 27, 2023
45f55d6
- Resolve lint and unit test errors
elipe17 Jul 27, 2023
2e0e69c
- small optimization to validator
elipe17 Jul 28, 2023
77aeaae
- Added tests for cat3 validators for T5 record
elipe17 Jul 28, 2023
9015026
- Fix lint errors
elipe17 Jul 28, 2023
0741e3a
- updated fields to correct types
elipe17 Jul 31, 2023
47a4f60
- update race/ethnicity
elipe17 Jul 31, 2023
cd3e4eb
Merge branch '1109-tanf-section2' into 1109-tanf-section2-validation
elipe17 Jul 31, 2023
d3ba5c2
- updated tests post merge
elipe17 Jul 31, 2023
2862dca
- Updated based on review feedback
elipe17 Jul 31, 2023
b8814da
- Fix lint error
elipe17 Jul 31, 2023
5694fe0
- Updating to the correct types
elipe17 Jul 31, 2023
10a901d
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Aug 1, 2023
437e83d
- Resolve conflicts
elipe17 Aug 1, 2023
a3214f2
- Moving field updates to seperate migration to see if they take place
elipe17 Aug 3, 2023
d66df76
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Aug 3, 2023
7211304
Revert "- Moving field updates to seperate migration to see if they t…
elipe17 Aug 3, 2023
8c28f58
- Revert migration 15 to original state
elipe17 Aug 3, 2023
e2c1761
Merge branch '1109-tanf-section2' into 1109-tanf-section2-validation
elipe17 Aug 3, 2023
b553900
- Merged base branch and updated tests/factories
elipe17 Aug 3, 2023
ebf6cc7
- Fixed test
elipe17 Aug 3, 2023
f5b03d8
- Fixed field names to correspond to model
elipe17 Aug 4, 2023
86debd3
Merge branch '1109-tanf-section2' into 1109-tanf-section2-validation
elipe17 Aug 4, 2023
9bf2612
- Remove duplicate function
elipe17 Aug 8, 2023
fbeae26
t7 model, index changes
jtimpe Aug 10, 2023
3b2d92f
add t7 to parser
jtimpe Aug 10, 2023
d924acf
update model mapping test
jtimpe Aug 10, 2023
c4b1096
add s3-s10
jtimpe Aug 10, 2023
4e73834
- Remove print statemtnt
elipe17 Aug 14, 2023
07bff86
- Resolved filter issue that made it seem like records werent being c…
elipe17 Aug 14, 2023
394ef94
- fix lint errors
elipe17 Aug 14, 2023
5a91763
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Aug 14, 2023
5a409bf
- correct form merge conflict
elipe17 Aug 14, 2023
2a155b6
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Aug 18, 2023
53c8789
- Added specific validators to avoid duplication
elipe17 Aug 21, 2023
2cf59a7
TANF Section 3 Parsing/Validation (#2649)
elipe17 Aug 22, 2023
08747ec
- Calling super to avoid duplicate code
elipe17 Aug 23, 2023
971bc36
- Added validators for transformed field
elipe17 Aug 25, 2023
f92e701
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Aug 28, 2023
8a9a88c
- Updating based on merge
elipe17 Aug 28, 2023
bf02c40
- Fixed remaining merge conflicts
elipe17 Aug 28, 2023
a7d858a
- Fix lint errors
elipe17 Aug 28, 2023
a663464
- update error messages based on validator updates
elipe17 Aug 28, 2023
6f3f970
Merge branch 'develop' into 1109-tanf-section2-validation
ADPennington Aug 28, 2023
2e9b779
- Corrected validator
elipe17 Aug 28, 2023
d1d64ec
Merge branch '1109-tanf-section2-validation' of https://github.com/ra…
elipe17 Aug 28, 2023
023fe51
- Resolved bug causing file to think it was encrytped after multiple …
elipe17 Aug 29, 2023
92f014b
Merge branch 'develop' into 1109-tanf-section2-validation
ADPennington Aug 29, 2023
ef14934
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Aug 29, 2023
e1db5bd
- UPdated migration
elipe17 Aug 29, 2023
25460d4
Merge branch '1109-tanf-section2-validation' into feature/1111-tanf-s…
elipe17 Aug 29, 2023
1e36eda
- Added transform fields
elipe17 Aug 30, 2023
2c5585a
- Stratified T7 to one record per month per section indicator and str…
elipe17 Aug 30, 2023
872b2f9
- Updated tests
elipe17 Aug 30, 2023
86d42fc
- Fix test
elipe17 Aug 30, 2023
0fd5d5c
- Add T7 factory
elipe17 Aug 30, 2023
63ac0da
- Fix lint error
elipe17 Aug 30, 2023
ddc13e3
- Remove test class until cat three validators exist
elipe17 Aug 31, 2023
e3c1f57
- fix lint errors
elipe17 Aug 31, 2023
5cb59c5
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Sep 1, 2023
a2d8fd2
- Fixing colliding migration
elipe17 Sep 1, 2023
3357b34
- Generating schemas instead of defining
elipe17 Sep 6, 2023
2242048
- Fix lint errors
elipe17 Sep 6, 2023
05fe9a8
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Sep 13, 2023
a65c137
- Updated based on review feedback
elipe17 Sep 15, 2023
dcdde2e
Merge branch 'develop' into feature/1111-tanf-section-4
jtimpe Sep 20, 2023
d77a521
rm 17/18
jtimpe Sep 20, 2023
7b58526
Merge branch 'develop' into feature/1111-tanf-section-4
jtimpe Sep 20, 2023
b8796b8
remake migration 18
jtimpe Sep 20, 2023
b01c373
Merge branch 'develop' into feature/1111-tanf-section-4
jtimpe Sep 26, 2023
b2563d9
fix merge error
jtimpe Sep 26, 2023
bcae3f4
fix merge error
jtimpe Sep 26, 2023
f426b61
fix merge error
jtimpe Sep 26, 2023
592e7b3
labels are stuck
jtimpe Sep 26, 2023
faffedf
rm
jtimpe Sep 26, 2023
dd1d02f
dont compute aggregates for section 3/4
jtimpe Sep 27, 2023
103804d
move save
jtimpe Sep 27, 2023
126b626
Update tdrs-backend/tdpservice/parsers/test/factories.py
jtimpe Sep 28, 2023
148535a
enhance t7 modeladmin
jtimpe Sep 28, 2023
e8d001a
fix rpt_month_year off by 1
jtimpe Sep 28, 2023
4f2b9bf
lint
jtimpe Sep 28, 2023
0d1d9d5
differentiate item 6a/6b/67 in t7 records
jtimpe Sep 28, 2023
07385d1
Merge branch 'develop' into feature/1111-tanf-section-4
jtimpe Sep 28, 2023
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
2 changes: 1 addition & 1 deletion tdrs-backend/tdpservice/parsers/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def get_schema_manager_options(program_type):
'T6': schema_defs.tanf.t6,
},
'S': {
# 'T7': schema_options.t7,
'T7': schema_defs.tanf.t7,
},
}
case 'SSP':
Expand Down
2 changes: 2 additions & 0 deletions tdrs-backend/tdpservice/parsers/schema_defs/tanf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
from .t4 import t4
from .t5 import t5
from .t6 import t6
from .t7 import t7

t1 = t1
t2 = t2
t3 = t3
t4 = t4
t5 = t5
t6 = t6
t7 = t7
51 changes: 51 additions & 0 deletions tdrs-backend/tdpservice/parsers/schema_defs/tanf/t7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Schema for TANF T7 Row."""

from ...util import SchemaManager
from ...fields import Field, TransformField
from ...row_schema import RowSchema
from ...transforms import calendar_quarter_to_rpt_month_year
from ... import validators
from tdpservice.search_indexes.models.tanf import TANF_T7

schemas = []

validator_index = 7
section_ind_index = 7
stratum_index = 8
families_index = 10
for i in range(1, 31):
schemas.append(
RowSchema(
model=TANF_T7,
quiet_preparser_errors=i > 1,
preparsing_validators=[
validators.notEmpty(0, 7),
validators.notEmpty(validator_index, validator_index + 24),
],
postparsing_validators=[],
fields=[
Field(item="0", name="RecordType", type='string', startIndex=0, endIndex=2,
required=True, validators=[]),
Field(item="3", name='CALENDAR_QUARTER', type='number', startIndex=2, endIndex=7,
required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.quarterIsValid()]),
TransformField(calendar_quarter_to_rpt_month_year(i % 3), item="3A", name='RPT_MONTH_YEAR', type='number',
ADPennington marked this conversation as resolved.
Show resolved Hide resolved
startIndex=2, endIndex=7, required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.dateMonthIsValid()]),
Field(item="4", name='TDRS_SECTION_IND', type='string', startIndex=section_ind_index,
endIndex=section_ind_index + 1, required=True, validators=[validators.oneOf(['1', '2'])]),
Field(item="5", name='STRATUM', type='string', startIndex=stratum_index,
endIndex=stratum_index + 2, required=True, validators=[validators.isInStringRange(1, 99)]),
Field(item="6A", name='FAMILIES_MONTH', type='number', startIndex=families_index,
ADPennington marked this conversation as resolved.
Show resolved Hide resolved
endIndex=families_index + 7, required=True, validators=[validators.isInLimits(0, 9999999)]),
]
)
)

index_offset = 0 if i % 3 != 0 else 24
validator_index += index_offset
section_ind_index += index_offset
stratum_index += index_offset
families_index += 7 if i % 3 != 0 else 10

t7 = SchemaManager(schemas=schemas)
3 changes: 3 additions & 0 deletions tdrs-backend/tdpservice/parsers/test/data/ADS.E2J.FTP4.TS06
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
HEADER20204S06 TAN1 N
T720204101006853700680540068454103000312400037850003180104000347400036460003583106000044600004360000325299000506200036070003385202000039100002740000499
TRAILER0000001
14 changes: 14 additions & 0 deletions tdrs-backend/tdpservice/parsers/test/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,17 @@ class Meta:
NUM_BIRTHS = 1
NUM_OUTWEDLOCK_BIRTHS = 1
NUM_CLOSED_CASES = 1

class TanfT7Factory(factory.django.DjangoModelFactory):
"""Generate TANF T6 record for testing."""
jtimpe marked this conversation as resolved.
Show resolved Hide resolved

class Meta:
"""Hardcoded meta data for TANF_T7."""

model = "search_indexes.TANF_T7"

CALENDAR_QUARTER = 20204
RPT_MONTH_YEAR = 202011
TDRS_SECTION_IND = '1'
STRATUM = '01'
FAMILIES_MONTH = 1
31 changes: 30 additions & 1 deletion tdrs-backend/tdpservice/parsers/test/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ..util import create_test_datafile
from .. import parse
from ..models import ParserError, ParserErrorCategoryChoices
from tdpservice.search_indexes.models.tanf import TANF_T1, TANF_T2, TANF_T3, TANF_T4, TANF_T5, TANF_T6
from tdpservice.search_indexes.models.tanf import TANF_T1, TANF_T2, TANF_T3, TANF_T4, TANF_T5, TANF_T6, TANF_T7
from tdpservice.search_indexes.models.ssp import SSP_M1, SSP_M2, SSP_M3
import logging

Expand Down Expand Up @@ -656,3 +656,32 @@ def test_parse_tanf_section3_file(tanf_section3_file):
assert first.NUM_CLOSED_CASES == 3884
assert second.NUM_CLOSED_CASES == 3881
assert third.NUM_CLOSED_CASES == 5453

@pytest.fixture
def tanf_section4_file(stt_user, stt):
"""Fixture for ADS.E2J.FTP4.TS06."""
return create_test_datafile('ADS.E2J.FTP4.TS06', stt_user, stt, "Stratum Data")

@pytest.mark.django_db()
def test_parse_tanf_section4_file(tanf_section4_file):
"""Test parsing TANF Section 4 submission."""
parse.parse_datafile(tanf_section4_file)

assert TANF_T7.objects.all().count() == 18

parser_errors = ParserError.objects.filter(file=tanf_section4_file)
assert parser_errors.count() == 0

t7_objs = TANF_T7.objects.all().order_by('FAMILIES_MONTH')

first = t7_objs.first()
sixth = t7_objs[5]

assert first.RPT_MONTH_YEAR == 202012
assert sixth.RPT_MONTH_YEAR == 202010

assert first.TDRS_SECTION_IND == '2'
assert sixth.TDRS_SECTION_IND == '2'

assert first.FAMILIES_MONTH == 274
assert sixth.FAMILIES_MONTH == 499
8 changes: 5 additions & 3 deletions tdrs-backend/tdpservice/search_indexes/admin/tanf.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ class TANF_T7Admin(admin.ModelAdmin):
"""ModelAdmin class for parsed T7 data files."""

list_display = [
'record',
'rpt_month_year',
'RecordType',
ADPennington marked this conversation as resolved.
Show resolved Hide resolved
'CALENDAR_QUARTER',
'RPT_MONTH_YEAR',
'datafile',
]

list_filter = [
'CALENDAR_QUARTER',
CreationDateFilter,
'rpt_month_year',
'RPT_MONTH_YEAR',
]
13 changes: 6 additions & 7 deletions tdrs-backend/tdpservice/search_indexes/documents/tanf.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,10 @@ class Django:

model = TANF_T7
fields = [
'record',
'rpt_month_year',
'fips_code',
'calendar_quarter',
'tdrs_section_ind',
'stratum',
'families',
"RecordType",
"CALENDAR_QUARTER",
"RPT_MONTH_YEAR",
"TDRS_SECTION_IND",
"STRATUM",
"FAMILIES_MONTH",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Generated by Django 3.2.15 on 2023-09-20 18:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('search_indexes', '0017_auto_20230914_1720'),
]

operations = [
migrations.RemoveField(
model_name='tanf_t7',
name='calendar_quarter',
),
migrations.RemoveField(
model_name='tanf_t7',
name='families',
),
migrations.RemoveField(
model_name='tanf_t7',
name='fips_code',
),
migrations.RemoveField(
model_name='tanf_t7',
name='record',
),
migrations.RemoveField(
model_name='tanf_t7',
name='rpt_month_year',
),
migrations.RemoveField(
model_name='tanf_t7',
name='stratum',
),
migrations.RemoveField(
model_name='tanf_t7',
name='tdrs_section_ind',
),
migrations.AddField(
model_name='tanf_t7',
name='CALENDAR_QUARTER',
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='tanf_t7',
name='FAMILIES_MONTH',
field=models.IntegerField(null=True),
),
migrations.AddField(
model_name='tanf_t7',
name='RPT_MONTH_YEAR',
field=models.IntegerField(null=True),
),
migrations.AddField(
model_name='tanf_t7',
name='RecordType',
field=models.CharField(max_length=156, null=True),
),
migrations.AddField(
model_name='tanf_t7',
name='STRATUM',
field=models.CharField(max_length=2, null=True),
),
migrations.AddField(
model_name='tanf_t7',
name='TDRS_SECTION_IND',
field=models.CharField(max_length=1, null=True),
),
]
16 changes: 7 additions & 9 deletions tdrs-backend/tdpservice/search_indexes/models/tanf.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,13 @@ class TANF_T7(models.Model):
related_name='t7_parent'
)

record = models.CharField(max_length=156, null=False, blank=False)
rpt_month_year = models.IntegerField(null=False, blank=False)
fips_code = models.CharField(max_length=100, null=False, blank=False)

calendar_quarter = models.IntegerField(null=False, blank=False)
tdrs_section_ind = models.CharField(
RecordType = models.CharField(max_length=156, null=True, blank=False)
CALENDAR_QUARTER = models.IntegerField(null=True, blank=True)
RPT_MONTH_YEAR = models.IntegerField(null=True, blank=False)
TDRS_SECTION_IND = models.CharField(
max_length=1,
null=False,
null=True,
blank=False
)
stratum = models.CharField(max_length=2, null=False, blank=False)
families = models.IntegerField(null=False, blank=False)
STRATUM = models.CharField(max_length=2, null=True, blank=False)
FAMILIES_MONTH = models.IntegerField(null=True, blank=False)
40 changes: 16 additions & 24 deletions tdrs-backend/tdpservice/search_indexes/test/test_model_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest
from faker import Faker
from django.db.utils import IntegrityError
from tdpservice.search_indexes import models
from tdpservice.search_indexes import documents
from tdpservice.parsers.util import create_test_datafile
Expand Down Expand Up @@ -346,44 +345,37 @@ def test_can_create_and_index_tanf_t7_submission(test_datafile):

submission = models.tanf.TANF_T7()
submission.datafile = test_datafile
submission.record = record_num
submission.rpt_month_year = 1
submission.fips_code = '2'
submission.calendar_quarter = 1
submission.tdrs_section_ind = '1'
submission.stratum = '1'
submission.families = 1
submission.RecordType = record_num
submission.CALENDAR_YEAR = 2020
submission.CALENDAR_QUARTER = 1
submission.TDRS_SECTION_IND = '1'
submission.STRATUM = '01'
submission.FAMILIES_MONTH_1 = 47655
submission.FAMILIES_MONTH_2 = 81982
submission.FAMILIES_MONTH_3 = 9999999

submission.save()

# No checks her because t7 records can't be parsed currently.
# assert submission.id is not None
assert submission.id is not None

# search = documents.tanf.TANF_T7DataSubmissionDocument.search().query(
# 'match',
# record=record_num
# )
# response = search.execute()
search = documents.tanf.TANF_T7DataSubmissionDocument.search().query(
'match',
RecordType=record_num
)
response = search.execute()

# assert response.hits.total.value == 1
assert response.hits.total.value == 1


@pytest.mark.django_db
def test_does_not_create_index_if_model_creation_fails():
"""Index creation shouldn't happen if saving a model errors."""
record_num = fake.uuid4()

with pytest.raises(IntegrityError):
submission = models.tanf.TANF_T7.objects.create(
record=record_num
# leave out a bunch of required fields
)

assert submission.id is None

search = documents.tanf.TANF_T7DataSubmissionDocument.search().query(
'match',
record=record_num
RecordType=record_num
)

response = search.execute()
Expand Down
Loading