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

2411 metadata parsed datafiles #2706

Merged
merged 157 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 150 commits
Commits
Show all changes
157 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
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
e01ac15
vscode merge conflict resolution (#2623)
andrew-jameson Jul 21, 2023
3d444a9
url change per me, want pipeline to run e2e
andrew-jameson Jul 26, 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
49222be
Minor lint fix for exception logging
andrew-jameson Aug 17, 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
40324b4
Merge branch 'feat/1613-case-aggregates'
raftmsohani Sep 20, 2023
02f022a
added the filters for datafile progtype
raftmsohani Sep 20, 2023
0f0d4b7
added url to admin filters
raftmsohani Sep 22, 2023
b2a0078
Merge branch 'develop' into 2411-metadata-parsed-datafiles-3
raftmsohani Sep 22, 2023
7451813
added datafile summary link to admin page
raftmsohani Sep 24, 2023
12d2a58
filtering parser errors
raftmsohani Sep 26, 2023
9363f04
Merge branch 'develop' into 2411-metadata-parsed-datafiles-3
raftmsohani Sep 27, 2023
fe08110
linting
raftmsohani Sep 27, 2023
24377b2
Test data_file admin page
raftmsohani Sep 28, 2023
4ba0395
corrected datafile id for test file
raftmsohani Sep 28, 2023
f74c2bb
linting
raftmsohani Sep 28, 2023
a5ccafa
Merge branch 'develop' into 2411-metadata-parsed-datafiles-3
raftmsohani Oct 2, 2023
54bdc62
Added deplay to cypress test
raftmsohani Oct 2, 2023
912a9a6
changed datafile summary filter
raftmsohani Oct 3, 2023
9b1c99a
Changed error report link
raftmsohani Oct 3, 2023
91c0068
Merge branch 'develop' into 2411-metadata-parsed-datafiles-3
ADPennington Oct 5, 2023
f9a7ac5
changed filter to reflect related name
raftmsohani Oct 5, 2023
c89ebd8
Merge branch 'develop' into 2411-metadata-parsed-datafiles-3
andrew-jameson Oct 6, 2023
ebf9956
Merge branch 'develop' into 2411-metadata-parsed-datafiles-3
andrew-jameson Oct 11, 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
77 changes: 77 additions & 0 deletions tdrs-backend/tdpservice/data_files/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,94 @@

from ..core.utils import ReadOnlyAdminMixin
from .models import DataFile, LegacyFileTransfer
from tdpservice.parsers.models import DataFileSummary, ParserError
from django.conf import settings
from django.utils.html import format_html

DOMAIN = settings.FRONTEND_BASE_URL

class DataFileSummaryStatusFilter(admin.SimpleListFilter):
"""Admin class filter for file status (accepted, rejected) for datafile model."""

title = 'status'
parameter_name = 'status'

def lookups(self, request, model_admin):
"""Return a list of tuples."""
return [
('Accepted', 'Accepted'),
('Rejected', 'Rejected'),
Copy link

Choose a reason for hiding this comment

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

we have a couple more statuses than just Accepted and Rejected, could they be added? also rather than create a custom filter class, you could add 'datafilesummary__status' to the DataFileAdmin's list_filter - i tested that out quickly and it correctly ports all the DataFileSummary.Status options without needing to hard code anything
image
image

]

def queryset(self, request, queryset):
"""Return a queryset."""
if self.value():
return queryset.filter(datafilesummary__status=self.value())
else:
return queryset


class DataFileSummaryPrgTypeFilter(admin.SimpleListFilter):
"""Admin class filter for Program Type on datafile model."""

title = 'Program Type'
parameter_name = 'program_type'

def lookups(self, request, model_admin):
"""Return a list of tuples."""
return [
('TAN', 'TAN'),
('SSP', 'SSP'),
]

def queryset(self, request, queryset):
"""Return a queryset."""
if self.value():
query_set_ids = [df.id for df in queryset if df.prog_type == self.value()]
return queryset.filter(id__in=query_set_ids)
else:
return queryset

@admin.register(DataFile)
class DataFileAdmin(ReadOnlyAdminMixin, admin.ModelAdmin):
"""Admin class for DataFile models."""

def status(self, obj):
"""Return the status of the data file summary."""
return DataFileSummary.objects.get(datafile=obj).status

def case_totals(self, obj):
"""Return the case totals."""
return DataFileSummary.objects.get(datafile=obj).case_aggregates

def error_report_link(self, obj):
"""Return the link to the error report."""
pe_len = ParserError.objects.filter(file=obj).count()

filtered_parserror_list_url = f'{DOMAIN}/admin/parsers/parsererror/?file=' + str(obj.id)
# have to find the error id from obj
return format_html("<a href='{url}'>{field}</a>",
field='Parser Error List: ' + str(pe_len) + " errors",
raftmsohani marked this conversation as resolved.
Show resolved Hide resolved
url=filtered_parserror_list_url)

error_report_link.allow_tags = True

def data_file_summary(self, obj):
"""Return the data file summary."""
df = DataFileSummary.objects.get(datafile=obj)
return format_html("<a href='{url}'>{field}</a>",
field=f'{df.id}' + ":" + df.get_status(),
elipe17 marked this conversation as resolved.
Show resolved Hide resolved
url=f"{DOMAIN}/admin/parsers/datafilesummary/{df.id}/change/")

list_display = [
'id',
'stt',
'year',
'quarter',
'section',
'version',
'data_file_summary',
'error_report_link',
]

list_filter = [
Expand All @@ -25,6 +100,8 @@ class DataFileAdmin(ReadOnlyAdminMixin, admin.ModelAdmin):
'user',
'year',
'version',
DataFileSummaryStatusFilter,
DataFileSummaryPrgTypeFilter
]

@admin.register(LegacyFileTransfer)
Expand Down
14 changes: 14 additions & 0 deletions tdrs-backend/tdpservice/data_files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ class Meta:
null=True
)

@property
def prog_type(self):
Copy link

Choose a reason for hiding this comment

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

not really specific to this PR, but similar logic is repeated everywhere and i keep thinking we should have a first-class member for the program type. similar to my other comment this would also allow you to use a native django list filter for the program type without creating a custom class

Copy link
Author

Choose a reason for hiding this comment

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

Having prog_type as property means calculation is done in backend server vs DB. While normally querying the DB is faster, there are cases where pushing the query into DB is not efficient since during writing to prog_type need a db_lock. An example is calculated values where property can change base on two, three different fields.
Having said that, in this case since prog_type only needs to be updated during the initial write, I agree with your suggestion

"""Return the program type for a given section."""
# e.g., 'SSP Closed Case Data'
if self.section.startswith('SSP'):
return 'SSP'
elif self.section.startswith('Tribal'):
return 'TAN' # problematic, do we need to infer tribal entirely from tribe/fips code?
else:
return 'TAN'

# TODO: if given a datafile (section), we can reverse back to the program b/c the
# section string has "tribal/ssp" in it, then process of elimination we have tanf

@property
def filename(self):
"""Return the correct filename for this data file."""
Expand Down
22 changes: 22 additions & 0 deletions tdrs-backend/tdpservice/data_files/test/test_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Test DataFileAdmin methods."""
import pytest
from django.contrib.admin.sites import AdminSite

from tdpservice.data_files.admin import DataFileAdmin
from tdpservice.data_files.models import DataFile
from tdpservice.data_files.test.factories import DataFileFactory
from tdpservice.parsers.test.factories import DataFileSummaryFactory
from django.conf import settings

@pytest.mark.django_db
def test_DataFileAdmin_status():
"""Test DataFileAdmin status method."""
data_file = DataFileFactory()
data_file_summary = DataFileSummaryFactory(datafile=data_file)
data_file_admin = DataFileAdmin(DataFile, AdminSite())

assert data_file_admin.status(data_file) == data_file_summary.status
assert data_file_admin.case_totals(data_file) == data_file_summary.case_aggregates
DOMAIN = settings.FRONTEND_BASE_URL
assert data_file_admin.error_report_link(data_file) == \
f"<a href='{DOMAIN}/admin/parsers/parsererror/?file={data_file.id}'>Parser Error List: 0 errors</a>"
Loading