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

1612 case aggregates frontend #2643

Merged
merged 200 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 187 commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
210b75c
saving state real quick
andrew-jameson Apr 3, 2023
d70e9c2
Merge branch 'develop' into feat/1613-minimal-retouch
andrew-jameson Apr 12, 2023
2c20472
finishing merge with latest
andrew-jameson Apr 12, 2023
9c0b25d
Missed old test script
andrew-jameson Apr 12, 2023
fba7f43
Added new test, more cleanup
andrew-jameson Apr 18, 2023
b948a5b
Updating unit tests in DFS, preparing for 1610
andrew-jameson Apr 26, 2023
c5796da
Merging in Jan's 1610 code for parserError useful-ness
andrew-jameson Apr 26, 2023
e6087fd
Revert "Merging in Jan's 1610 code for parserError useful-ness"
andrew-jameson Apr 26, 2023
744ba4d
update to test to use dfs fixture
andrew-jameson Apr 26, 2023
6bb2017
saving state before new 1610 merge
andrew-jameson Apr 27, 2023
bd4cc4e
Merged develop and 1610 into 1613 latest
andrew-jameson Apr 27, 2023
1316a70
Resolving merge conflicts with 1610.
andrew-jameson Apr 27, 2023
e118ff3
Linting changes and comparing to 1610
andrew-jameson Apr 27, 2023
21f8954
Some unit test linting but inherited 1610 issues
andrew-jameson Apr 27, 2023
618d300
Re-ordering job to run tests vs lint first.
andrew-jameson Apr 27, 2023
953c9ce
Updates to linting and unit tests.
andrew-jameson Apr 27, 2023
b8c5786
Merge branch 'feature/1610-parser-error-generator' into feat/1613-min…
andrew-jameson Apr 28, 2023
70692f3
Fixing linting.
andrew-jameson Apr 28, 2023
d9f3a43
Update tdrs-backend/setup.cfg
andrew-jameson Apr 28, 2023
3db0af6
updates per PR.
andrew-jameson May 8, 2023
83009cb
Excluding trailers for rejection
andrew-jameson May 8, 2023
b11c310
Merge branch 'feature/1610-parser-error-generator' into feat/1613-min…
andrew-jameson May 8, 2023
223ff08
VSCode merge resolution is garbage.
andrew-jameson May 8, 2023
297e13d
Fixing precheck for not implemented types
andrew-jameson May 24, 2023
e9bd47e
Merge branch 'feature/1610-parser-error-generator' into feat/1613-min…
andrew-jameson Jun 5, 2023
c0f5a74
Updating to error-handle not implemented schema types
andrew-jameson Jun 5, 2023
5fca243
- Updated view to show latest datafiles
elipe17 Jun 28, 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
45f296d
- Fixed failing test
elipe17 Jul 10, 2023
c0bce69
add adminUrl to deployment cypress overrides
jtimpe May 5, 2023
57c179d
Adding "beta" banners to relevant error report sections (#2522)
andrew-jameson Jun 2, 2023
8e7d0e3
Create sprint-73-summary.md (#2565)
Smithh-Co Jun 8, 2023
bd3558f
hotfix for large file sizes (#2542)
andrew-jameson Jun 8, 2023
2946dad
updating validation error language
jtimpe Jun 12, 2023
d9d6be9
accidentally included coding challenge
jtimpe Jun 12, 2023
5cdb886
rm comments
jtimpe Jun 12, 2023
fe32cdc
2550 deactivation email link (#2557)
elipe17 Jun 20, 2023
c26703e
Update README.md (#2577)
lfrohlich Jun 20, 2023
075ff86
Create 2023, Spring - Testing CSV & Excel-based error reports.md
reitermb Jun 21, 2023
2ff7d2e
Update README.md
reitermb Jun 21, 2023
093f67f
Updating deliverable links (#2584)
andrew-jameson Jun 21, 2023
9534d25
User viewset not returning/duplicating users (#2573)
elipe17 Jun 21, 2023
9a392ba
Update cf os (#2523)
elipe17 Jun 22, 2023
f8d75cc
Item Number Mismatch (#2578)
elipe17 Jun 23, 2023
a623e00
pipeline filtering (#2538)
George-Hudson Jun 27, 2023
b6d8b77
Hotfix Devops/2457 path filtering for documentation (#2597)
George-Hudson Jun 29, 2023
0dcd36a
Create sprint-74-summary.md (#2596)
Smithh-Co Jun 29, 2023
9aef162
added URL filters (#2580)
raftmsohani Jul 5, 2023
91cc331
Create sprint-75-summary.md (#2608)
Smithh-Co Jul 10, 2023
baffaba
Create sprint-76-summary.md (#2609)
Smithh-Co Jul 10, 2023
b905667
- Resolved failing tests
elipe17 Jul 10, 2023
29fa8b8
- Corrected merge thrash
elipe17 Jul 10, 2023
ac9b065
- Using randbits to generate pk to get around confilcting sequence pks
elipe17 Jul 10, 2023
6c8b3c4
Revert "- Using randbits to generate pk to get around confilcting seq…
elipe17 Jul 10, 2023
88d4b62
- Updating region in fixture instead of factory
elipe17 Jul 10, 2023
cb5077c
- Moved datafile reference to avoid confusion
elipe17 Jul 10, 2023
21b7d66
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Jul 10, 2023
6d3dfbe
pushing up incomplete codebase
andrew-jameson Jul 11, 2023
fc02fd7
Other unit tests now have passed w/ good error handling
andrew-jameson Jul 11, 2023
e137609
Working tests, need to get setup for case aggregates populating via DB
andrew-jameson Jul 11, 2023
9e4e431
- Updated queries
elipe17 Jul 12, 2023
af90565
minor improvement to month2int
andrew-jameson Jul 12, 2023
c5196fb
Merge branch '2579-latest-data' into feat/1613-case-aggregates
elipe17 Jul 12, 2023
4fc63eb
- Fixing most merge errors
elipe17 Jul 12, 2023
cc39ddd
- Fixing functions
elipe17 Jul 12, 2023
a3239c5
- Updated queries based on generic relation
elipe17 Jul 12, 2023
29f52e6
- Updated queries to count by case number instead of record number
elipe17 Jul 12, 2023
89278db
- Added route
elipe17 Jul 12, 2023
e078f50
- updated tests to include dfs
elipe17 Jul 12, 2023
2149f07
Merge branch 'feat/1613-minimal-retouch' into feat/1613-case-aggregates
andrew-jameson Jul 13, 2023
0fbaf77
Cleaning up most comments that are no longer necessary and fixed lint…
andrew-jameson Jul 13, 2023
f7c6772
making minor updates, still broken tests.
andrew-jameson Jul 14, 2023
46a6d73
updating pipfile.lock and rebuild image resolved test issues
andrew-jameson Jul 14, 2023
f162423
Reorganizing tests, still failing in test_parse.py
andrew-jameson Jul 14, 2023
cb01bd3
deleted summary file, split into other test scripts.
andrew-jameson Jul 14, 2023
a194462
Fixed missing self reference.
andrew-jameson Jul 14, 2023
c3bfa54
Linting fixes.
andrew-jameson Jul 17, 2023
534e635
Found reference failure in deployed env.
andrew-jameson Jul 18, 2023
5e79786
Removing extra returns for missing record type.
andrew-jameson Jul 18, 2023
b51a47a
Merge branch 'develop' into feat/1613-minimal-retouch
andrew-jameson Jul 18, 2023
1eb7e9a
lint fix
andrew-jameson Jul 19, 2023
15f67ce
Merge branch 'feat/1613-minimal-retouch' into feat/1613-case-aggregates
andrew-jameson Jul 19, 2023
a6d528e
Addressed invocation of datafile for failing test
andrew-jameson Jul 19, 2023
ef2793e
lint update for whitespace
andrew-jameson Jul 19, 2023
9243672
Intermediary commit, broken test
andrew-jameson Jul 20, 2023
ea3f091
add reverse relation
jtimpe Jul 20, 2023
9062313
frontend summary status
jtimpe Jul 20, 2023
bb158e0
new assignemnts in util
andrew-jameson Jul 20, 2023
dbac144
- updated rejected query to correctly count objs
elipe17 Jul 20, 2023
755b5bb
Merge branch 'feat/1613-case-aggregates' of https://github.com/raft-t…
elipe17 Jul 20, 2023
2c7efd6
- Fixing most tests
elipe17 Jul 20, 2023
e5108b2
- Fixed user error. Swapped numbers by accident.
elipe17 Jul 20, 2023
ff1e2b8
- make region None to avoid PK collision
elipe17 Jul 20, 2023
496a651
- Fix lint errors
elipe17 Jul 20, 2023
aed64f9
- Updating to avoid warning
elipe17 Jul 20, 2023
76f63b5
add acceptance icon
jtimpe Jul 20, 2023
5431579
add reverse relationship to summary model
jtimpe Jul 20, 2023
0193d9f
Merge branch 'feat/1613-case-aggregates' into feature/1610-frontend-p…
jtimpe Jul 20, 2023
e01ac15
vscode merge conflict resolution (#2623)
andrew-jameson Jul 21, 2023
81e5c21
add a pending status
jtimpe Jul 24, 2023
d3af83b
add acceptance status tests
jtimpe Jul 24, 2023
f7e5aba
update warning icon
jtimpe Jul 24, 2023
b55f40c
rm old assert
jtimpe Jul 24, 2023
3b1fa65
update rejected icon
jtimpe Jul 24, 2023
4f743cc
add case aggregates to submission history
jtimpe Jul 24, 2023
3d444a9
url change per me, want pipeline to run e2e
andrew-jameson Jul 26, 2023
1930755
update case aggregate columns
jtimpe Jul 31, 2023
70fb34f
update col names
jtimpe Aug 1, 2023
d3bceb7
Merge branch 'develop' into feat/1613-case-aggregates
andrew-jameson Aug 2, 2023
3cb28b9
Upgraded to querysets, fix PR comments, PE str
andrew-jameson Aug 7, 2023
94d4b36
Merge develop/remote into local
andrew-jameson Aug 7, 2023
90709a3
missing : not caught locally
andrew-jameson Aug 7, 2023
d55a917
Merge branch 'develop' into feat/1613-case-aggregates
andrew-jameson Aug 7, 2023
ad8ab50
Feat/1613 merge 2 (#2650)
andrew-jameson Aug 7, 2023
1648b0c
Merge branch 'develop' into feat/1613-case-aggregates
andrew-jameson Aug 8, 2023
07b5215
Merge branch 'feat/1613-case-aggregates' of github.com:raft-tech/TANF…
andrew-jameson Aug 8, 2023
3af7440
icontains
andrew-jameson Aug 8, 2023
b987399
tests
andrew-jameson Aug 8, 2023
091c8d9
Changing dict structure per 1612.
andrew-jameson Aug 8, 2023
ebeaec8
fixed tests and lint issues, parse is too complex
andrew-jameson Aug 9, 2023
6fbcebf
schema_manager replaces schema check
andrew-jameson Aug 9, 2023
6634979
Saving state prior to merge-conflict.
andrew-jameson Aug 9, 2023
9db047b
Merge branch 'develop' into feat/1613-case-aggregates
andrew-jameson Aug 9, 2023
8dae7da
Adopting latest manager, removing old error style.
andrew-jameson Aug 9, 2023
0887b89
Commented out t6 line during Office hours
andrew-jameson Aug 9, 2023
b9daa9d
minor reference update
andrew-jameson Aug 9, 2023
a060883
Acclimating to schemaManager
andrew-jameson Aug 11, 2023
eaab681
lint-fix isinstance
andrew-jameson Aug 11, 2023
d8b7672
syntax mistake with isinstance
andrew-jameson Aug 11, 2023
af932cd
Apply suggestions from code review
andrew-jameson Aug 11, 2023
e4fabbf
reverting search_index merge artifacts.
andrew-jameson Aug 11, 2023
181d48d
adjusting for removing unused "get-schema()"
andrew-jameson Aug 11, 2023
8564f13
whitespace lint
andrew-jameson Aug 11, 2023
16ebc55
Feedback from Jan
andrew-jameson Aug 14, 2023
eee7cba
Ensuring tests run/work.
andrew-jameson Aug 14, 2023
f83c019
Ensure we have leading zero in rptmonthyear.
andrew-jameson Aug 14, 2023
cfc01a2
Merge branch 'feat/1613-case-aggregates' into feature/1610-frontend-p…
jtimpe Aug 16, 2023
52af865
Merge branch 'feature/1610-frontend-parsing-status' into 1612-case-ag…
jtimpe Aug 16, 2023
49222be
Minor lint fix for exception logging
andrew-jameson Aug 17, 2023
568454c
fix migration
jtimpe Aug 22, 2023
7fa3d4c
add backend partially accepted status
jtimpe Aug 23, 2023
44eacbc
add frontend partially accepted status
jtimpe Aug 23, 2023
2caeb99
add partially accepted test
jtimpe Aug 23, 2023
54ee1fe
Merge branch 'feature/1610-frontend-parsing-status' into 1612-case-ag…
jtimpe Aug 23, 2023
01dcf88
rm accidental commit
jtimpe Aug 24, 2023
b294cec
rm unused variable
jtimpe Aug 24, 2023
23f21c4
Merge branch 'feature/1610-frontend-parsing-status' into 1612-case-ag…
jtimpe Aug 24, 2023
87cb309
conditional submission history
jtimpe Aug 24, 2023
82d7aea
Merge branch 'feat/1613-case-aggregates' into 1612-case-aggregates-fr…
jtimpe Aug 24, 2023
4908433
fix test
jtimpe Aug 24, 2023
d76d5af
Merge branch 'develop' into feat/1613-case-aggregates
andrew-jameson Aug 31, 2023
d398ef7
resolving merge conflict problems
andrew-jameson Aug 31, 2023
6c21179
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Sep 1, 2023
3bbe4b3
Merge branch 'develop' into feat/1613-case-aggregates
andrew-jameson Sep 5, 2023
2a39e5d
fixing tests from merge conflicts.
andrew-jameson Sep 5, 2023
9d97a33
- fixed migration reference
elipe17 Sep 5, 2023
3b4cf3e
dumb lint fix
andrew-jameson Sep 5, 2023
0680e5b
- Fixed render error
elipe17 Sep 5, 2023
0b6b541
Merge branch 'feat/1613-case-aggregates' of https://github.com/raft-t…
elipe17 Sep 5, 2023
064b415
Adding section
elipe17 Sep 6, 2023
9df10f4
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Sep 7, 2023
eae8d3c
- Resolved type mismatches causing render failures
elipe17 Sep 7, 2023
8408f66
- Adding branch coverage
elipe17 Sep 8, 2023
b99a17c
- Fix lint errors
elipe17 Sep 8, 2023
6fd7d52
- Fix lint errors
elipe17 Sep 8, 2023
b3af51a
- Consolodated tetss
elipe17 Sep 11, 2023
96a3227
Merge branch 'develop' into feat/1613-case-aggregates
andrew-jameson Sep 18, 2023
8cc1357
reducing line length for lint
andrew-jameson Sep 18, 2023
84a0de4
Merge branch 'develop' into feat/1613-case-aggregates
ADPennington Sep 19, 2023
12dd45c
- updated maxWidth to be percentage
elipe17 Sep 19, 2023
221f25f
Merge branch 'develop' of https://github.com/raft-tech/TANF-app into …
elipe17 Sep 19, 2023
30cd7e5
Merge branch 'feat/1613-case-aggregates' of https://github.com/raft-t…
elipe17 Sep 19, 2023
ee3f907
Moving DFS migration into it's own file to avoid conflicts.
andrew-jameson Sep 20, 2023
cd07fea
Merge branch 'develop' into feat/1613-case-aggregates
ADPennington Sep 20, 2023
985845b
Merge branch 'feat/1613-case-aggregates' into 1612-case-aggregates-fr…
jtimpe Sep 22, 2023
25b1ba3
rename migrations
jtimpe Sep 22, 2023
cf7eee8
left align error report text
jtimpe Sep 22, 2023
985e956
github got stuck :(
jtimpe Sep 25, 2023
1bc226e
rm comment
jtimpe Sep 25, 2023
1cb52f5
Merge branch 'feat/1613-case-aggregates' of https://github.com/raft-t…
elipe17 Sep 25, 2023
a7b603a
Merge branch '1612-case-aggregates-frontend' of https://github.com/ra…
elipe17 Sep 25, 2023
291e0bc
merge develop into 1612
jtimpe Sep 26, 2023
ee4447f
Merge branch 'develop' into 1612-case-aggregates-frontend
ADPennington Sep 29, 2023
64ee218
rm margin, add text for no error report
jtimpe Sep 29, 2023
0d60e46
fix tests
jtimpe Sep 29, 2023
1967766
Merge branch 'develop' into 1612-case-aggregates-frontend
jtimpe Sep 29, 2023
be3db45
Merge branch 'develop' into 1612-case-aggregates-frontend
jtimpe Oct 4, 2023
1e20abb
fix ssp case aggregates display
jtimpe Oct 4, 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
6 changes: 3 additions & 3 deletions .circleci/build-and-test/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
- checkout
- docker-compose-check
- docker-compose-up-backend
- run:
name: Execute Python Linting Test
command: cd tdrs-backend; docker-compose run --rm web bash -c "flake8 ."
- run:
name: Run Unit Tests And Create Code Coverage Report
command: |
cd tdrs-backend;
docker-compose run --rm web bash -c "./wait_for_services.sh && pytest --cov-report=xml"
- run:
name: Execute Python Linting Test
command: cd tdrs-backend; docker-compose run --rm web bash -c "flake8 ."
- upload-codecov:
component: backend
coverage-report: ./tdrs-backend/coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ workflows:
- develop
- main
- master
- /^release.*/
- /^release.*/

1 change: 0 additions & 1 deletion scripts/zap-scanner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ ZAP_CLI_OPTIONS="\
-config globalexcludeurl.url_list.url\(21\).regex='^https:\/\/.*\.identitysandbox.gov\/.*$' \
-config globalexcludeurl.url_list.url\(21\).description='Site - IdentitySandbox.gov' \
-config globalexcludeurl.url_list.url\(21\).enabled=true \

-config spider.postform=true"

# How long ZAP will crawl the app with the spider process
Expand Down
1 change: 1 addition & 0 deletions tdrs-backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tdrs-backend/docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ services:
build: .
command: >
bash -c "./wait_for_services.sh &&
./gunicorn_start.sh &&
./gunicorn_start.sh &&
celery -A tdpservice.settings worker -l info"
ports:
- "5555:5555"
Expand All @@ -106,5 +106,5 @@ volumes:

networks:
default:
external:
name: external-net
name: external-net
external: true
2 changes: 1 addition & 1 deletion tdrs-backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ volumes:

networks:
default:
external:
name: external-net
external: true
3 changes: 3 additions & 0 deletions tdrs-backend/tdpservice/data_files/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from tdpservice.security.models import ClamAVFileScan
from tdpservice.stts.models import STT
from tdpservice.users.models import User
from tdpservice.parsers.serializers import DataFileSummarySerializer
logger = logging.getLogger(__name__)

class DataFileSerializer(serializers.ModelSerializer):
Expand All @@ -22,6 +23,7 @@ class DataFileSerializer(serializers.ModelSerializer):
user = serializers.PrimaryKeyRelatedField(queryset=User.objects.all())
ssp = serializers.BooleanField(write_only=True)
has_error = serializers.SerializerMethodField()
summary = DataFileSummarySerializer(many=False, read_only=True)

class Meta:
"""Metadata."""
Expand All @@ -45,6 +47,7 @@ class Meta:
's3_location',
's3_versioning_id',
'has_error',
'summary'
]

read_only_fields = ("version",)
Expand Down
2 changes: 1 addition & 1 deletion tdrs-backend/tdpservice/data_files/test/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Meta:
extension = "txt"
section = "Active Case Data"
quarter = "Q1"
year = "2020"
year = 2020
version = 1
user = factory.SubFactory(UserFactory)
stt = factory.SubFactory(STTFactory)
Expand Down
7 changes: 7 additions & 0 deletions tdrs-backend/tdpservice/parsers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ class ParserErrorAdmin(admin.ModelAdmin):
]


class DataFileSummaryAdmin(admin.ModelAdmin):
"""ModelAdmin class for DataFileSummary objects generated in parsing."""

list_display = ['status', 'case_aggregates', 'datafile']


admin.site.register(models.ParserError, ParserErrorAdmin)
admin.site.register(models.DataFileSummary, DataFileSummaryAdmin)
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ class Migration(migrations.Migration):
model_name='parsererror',
name='error_type',
field=models.TextField(choices=[('1', 'File pre-check'), ('2', 'Record value invalid'), ('3', 'Record value consistency'), ('4', 'Case consistency'), ('5', 'Section consistency'), ('6', 'Historical consistency')], max_length=128),
),
)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.15 on 2023-07-20 20:50

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('data_files', '0012_datafile_s3_versioning_id'),
('parsers', '0006_auto_20230810_1500'),
]

operations = [
migrations.AlterField(
model_name='datafilesummary',
name='datafile',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='summary', to='data_files.datafile'),
),
]
24 changes: 24 additions & 0 deletions tdrs-backend/tdpservice/parsers/migrations/0007_datafilesummary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.15 on 2023-09-20 15:35

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('data_files', '0012_datafile_s3_versioning_id'),
('parsers', '0006_auto_20230810_1500'),
]

operations = [
migrations.CreateModel(
name='DataFileSummary',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('status', models.CharField(choices=[('Pending', 'Pending'), ('Accepted', 'Accepted'), ('Accepted with Errors', 'Accepted With Errors'), ('Rejected', 'Rejected')], default='Pending', max_length=50)),
('case_aggregates', models.JSONField(null=True)),
('datafile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='data_files.datafile')),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.15 on 2023-08-23 12:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('parsers', '0007_alter_datafilesummary_datafile'),
]

operations = [
migrations.AlterField(
model_name='datafilesummary',
name='status',
field=models.CharField(choices=[('Pending', 'Pending'), ('Accepted', 'Accepted'), ('Accepted with Errors', 'Accepted With Errors'), ('Partially Accepted with Errors', 'Partially Accepted'), ('Rejected', 'Rejected')], default='Pending', max_length=50),
),
]
52 changes: 50 additions & 2 deletions tdrs-backend/tdpservice/parsers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.utils.translation import gettext_lazy as _
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType

from tdpservice.data_files.models import DataFile

class ParserErrorCategoryChoices(models.TextChoices):
"""Enum of ParserError error_type."""
Expand Down Expand Up @@ -62,8 +62,56 @@ def __repr__(self):

def __str__(self):
"""Return a string representation of the model."""
return f"error_message: {self.error_message}"
return f"ParserError {self.__dict__}"

def _get_error_message(self):
"""Return the error message."""
return self.error_message

class DataFileSummary(models.Model):
"""Aggregates information about a parsed file."""

class Status(models.TextChoices):
"""Enum for status of parsed file."""

PENDING = "Pending" # file has been uploaded, but not validated
ACCEPTED = "Accepted"
ACCEPTED_WITH_ERRORS = "Accepted with Errors"
PARTIALLY_ACCEPTED = "Partially Accepted with Errors"
REJECTED = "Rejected"

status = models.CharField(
max_length=50,
choices=Status.choices,
default=Status.PENDING,
)

datafile = models.OneToOneField(DataFile, on_delete=models.CASCADE, related_name="summary")

case_aggregates = models.JSONField(null=True, blank=False)

def get_status(self):
"""Set and return the status field based on errors and models associated with datafile."""
errors = ParserError.objects.filter(file=self.datafile)
[print(error) for error in errors]

# excluding row-level pre-checks and trailer pre-checks.
precheck_errors = errors.filter(error_type=ParserErrorCategoryChoices.PRE_CHECK)\
.exclude(field_name="Record_Type")\
.exclude(error_message__icontains="trailer")\
.exclude(error_message__icontains="Unknown Record_Type was found.")

row_precheck_errors = errors.filter(error_type=ParserErrorCategoryChoices.PRE_CHECK)\
.filter(error_message__icontains="Unknown Record_Type was found.")\
.exclude(error_message__icontains="trailer")

if errors is None:
return DataFileSummary.Status.PENDING
elif errors.count() == 0:
return DataFileSummary.Status.ACCEPTED
elif precheck_errors.count() > 0:
return DataFileSummary.Status.REJECTED
elif row_precheck_errors.count() > 0:
return DataFileSummary.Status.PARTIALLY_ACCEPTED
else:
return DataFileSummary.Status.ACCEPTED_WITH_ERRORS
86 changes: 20 additions & 66 deletions tdrs-backend/tdpservice/parsers/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def parse_datafile(datafile):

section_is_valid, section_error = validators.validate_header_section_matches_submission(
datafile,
program_type,
section,
util.get_section_reference(program_type, section),
util.make_generate_parser_error(datafile, 1)
)

if not section_is_valid:
Expand Down Expand Up @@ -123,7 +123,6 @@ def parse_datafile_lines(datafile, program_type, section, is_encrypted):
errors = {}

line_number = 0
schema_manager_options = get_schema_manager_options(program_type)

unsaved_records = {}
unsaved_parser_errors = {}
Expand Down Expand Up @@ -180,11 +179,9 @@ def parse_datafile_lines(datafile, program_type, section, is_encrypted):
prev_sum = header_count + trailer_count
continue

schema_manager = get_schema_manager(line, section, schema_manager_options)

schema_manager.update_encrypted_fields(is_encrypted)
schema_manager = get_schema_manager(line, section, program_type)

records = manager_parse_line(line, schema_manager, generate_error)
records = manager_parse_line(line, schema_manager, generate_error, is_encrypted)

record_number = 0
for i in range(len(records)):
Expand Down Expand Up @@ -236,68 +233,25 @@ def parse_datafile_lines(datafile, program_type, section, is_encrypted):
return errors


def manager_parse_line(line, schema_manager, generate_error):
def manager_parse_line(line, schema_manager, generate_error, is_encrypted=False):
"""Parse and validate a datafile line using SchemaManager."""
if schema_manager.schemas:
try:
schema_manager.update_encrypted_fields(is_encrypted)
records = schema_manager.parse_and_validate(line, generate_error)
return records
except AttributeError as e:
logging.error(e)
return [(None, False, [
generate_error(
schema=None,
error_category=ParserErrorCategoryChoices.PRE_CHECK,
error_message="Unknown Record_Type was found.",
record=None,
field="Record_Type",
)
])]

logger.debug("Record Type is missing from record.")
return [(None, False, [
generate_error(
schema=None,
error_category=ParserErrorCategoryChoices.PRE_CHECK,
error_message="Record Type is missing from record.",
record=None,
field=None
)
])]


def get_schema_manager_options(program_type):
"""Return the allowed schema options."""
match program_type:
case 'TAN':
return {
'A': {
'T1': schema_defs.tanf.t1,
'T2': schema_defs.tanf.t2,
'T3': schema_defs.tanf.t3,
},
'C': {
'T4': schema_defs.tanf.t4,
'T5': schema_defs.tanf.t5,
},
'G': {
'T6': schema_defs.tanf.t6,
},
'S': {
# 'T7': schema_options.t7,
},
}
case 'SSP':
return {
'A': {
'M1': schema_defs.ssp.m1,
'M2': schema_defs.ssp.m2,
'M3': schema_defs.ssp.m3,
},
'C': {
# 'M4': schema_options.m4,
# 'M5': schema_options.m5,
},
'G': {
# 'M6': schema_options.m6,
},
'S': {
# 'M7': schema_options.m7,
},
}
# case tribal?
return None


def get_schema_manager(line, section, schema_options):
def get_schema_manager(line, section, program_type):
"""Return the appropriate schema for the line."""
line_type = line[0:2]
return schema_options.get(section, {}).get(line_type, util.SchemaManager([]))
return util.get_program_model(program_type, section, line_type)
2 changes: 1 addition & 1 deletion tdrs-backend/tdpservice/parsers/row_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run_preparsing_validators(self, line, generate_error):
error_category=ParserErrorCategoryChoices.PRE_CHECK,
error_message=validator_error,
record=None,
field=None
field="Record_Type"
)
)

Expand Down
2 changes: 1 addition & 1 deletion tdrs-backend/tdpservice/parsers/schema_defs/tanf/t1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Schema for HEADER row of all submission types."""
"""Schema for t1 record types."""

from ...util import SchemaManager
from ...fields import Field
Expand Down
Loading
Loading