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

3014 - Outdated submissions banner #3231

Merged
merged 26 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3357e84
show banner and hide errors if file submitted before 5/31/2024
jtimpe Oct 11, 2024
14cc136
add tests
jtimpe Oct 11, 2024
7ee53a6
more descriptive param names
jtimpe Oct 15, 2024
4e0b1bb
Merge branch 'develop' into 3014-outdated-submissions-banner
jtimpe Oct 17, 2024
b1a89bd
Merge branch 'develop' into 3014-outdated-submissions-banner
ADPennington Oct 17, 2024
f305d2a
Merge branch 'develop' into 3014-outdated-submissions-banner
ADPennington Oct 18, 2024
b098d05
include reparse in data files api response
jtimpe Oct 24, 2024
a1ffb0d
check reparse finished_at if submission outdated
jtimpe Oct 24, 2024
82d0bb6
lint, clean up comments
jtimpe Oct 24, 2024
3eb696f
Merge branch 'develop' into 3014-outdated-submissions-banner
jtimpe Oct 24, 2024
d7291fb
Merge branch 'develop' into 3014-outdated-submissions-banner
ADPennington Oct 24, 2024
9ff75dc
Merge branch 'develop' into 3014-outdated-submissions-banner
ADPennington Oct 25, 2024
eb8f661
move outdated submission processing to backend, make configurable
jtimpe Oct 29, 2024
cc63781
revert reparse_file_metas change
jtimpe Oct 29, 2024
11fc447
add reprocessed indicators to submission history tables
jtimpe Oct 29, 2024
15dafb6
Merge branch 'develop' into 3014-outdated-submissions-banner
jtimpe Oct 29, 2024
caf1c8a
update outdated error report language
jtimpe Nov 5, 2024
607b51e
Merge branch 'develop' into 3014-outdated-submissions-banner
jtimpe Nov 5, 2024
b0d3232
update language
jtimpe Nov 5, 2024
825f5b3
Merge branch 'develop' into 3014-outdated-submissions-banner
jtimpe Nov 6, 2024
18d7363
fix date compare
jtimpe Nov 7, 2024
d988e2d
remove old submissions banner, column text, serializer data
jtimpe Nov 8, 2024
a098543
rm tests
jtimpe Nov 8, 2024
28d4b78
rm unused
jtimpe Nov 8, 2024
4b278d1
rm unused properties, rename used property
jtimpe Nov 13, 2024
11abfb5
Merge branch 'develop' into 3014-outdated-submissions-banner
jtimpe Nov 15, 2024
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
31 changes: 29 additions & 2 deletions tdrs-backend/tdpservice/data_files/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework import serializers
from tdpservice.parsers.models import ParserError
from tdpservice.data_files.errors import ImmutabilityError
from tdpservice.data_files.models import DataFile
from tdpservice.data_files.models import DataFile, ReparseFileMeta
from tdpservice.data_files.validators import (
validate_file_extension,
validate_file_infection,
Expand All @@ -12,8 +12,26 @@
from tdpservice.stts.models import STT
from tdpservice.users.models import User
from tdpservice.parsers.serializers import DataFileSummarySerializer


logger = logging.getLogger(__name__)


class ReparseFileMetaSerializer(serializers.ModelSerializer):
"""Serializer for ReparseFileMeta class."""

class Meta:
"""Meta class."""

model = ReparseFileMeta
Copy link
Collaborator

Choose a reason for hiding this comment

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

✔️

Screenshot 2024-11-15 092322

fields = [
'finished',
'success',
'started_at',
'finished_at',
]


class DataFileSerializer(serializers.ModelSerializer):
"""Serializer for Data files."""

Expand All @@ -23,6 +41,7 @@ class DataFileSerializer(serializers.ModelSerializer):
ssp = serializers.BooleanField(write_only=True)
has_error = serializers.SerializerMethodField()
summary = DataFileSummarySerializer(many=False, read_only=True)
latest_reparse_file_meta = serializers.SerializerMethodField()

class Meta:
"""Metadata."""
Expand All @@ -46,7 +65,8 @@ class Meta:
's3_location',
's3_versioning_id',
'has_error',
'summary'
'summary',
'latest_reparse_file_meta',
]

read_only_fields = ("version",)
Expand All @@ -56,6 +76,13 @@ def get_has_error(self, obj):
parser_errors = ParserError.objects.filter(file=obj.id)
return len(parser_errors) > 0

def get_latest_reparse_file_meta(self, instance):
"""Return related reparse_file_metas, ordered by finished_at decending."""
reparse_file_metas = instance.reparse_file_metas.all().order_by('-finished_at')
if reparse_file_metas.count() > 0:
return ReparseFileMetaSerializer(reparse_file_metas.first(), many=False, read_only=True).data
return None

def create(self, validated_data):
"""Create a new entry with a new version number."""
ssp = validated_data.pop('ssp')
Expand Down
1 change: 1 addition & 0 deletions tdrs-backend/tdpservice/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import logging.handlers
import os
from django.utils.dateparse import parse_datetime
from distutils.util import strtobool
from os.path import join
from typing import Any, Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useDispatch } from 'react-redux'
import {
SubmissionSummaryStatusIcon,
formatDate,
hasReparsed,
getReprocessedDate,
downloadFile,
downloadErrorReport,
getErrorReportStatus,
} from './helpers'

const MonthSubRow = ({ data }) =>
Expand All @@ -24,17 +26,13 @@ const MonthSubRow = ({ data }) =>

const CaseAggregatesRow = ({ file }) => {
const dispatch = useDispatch()
const errorFileName = `${file.year}-${file.quarter}-${file.section}`

return (
<>
<tr>
<th scope="rowgroup" rowSpan={3}>
{formatDate(file.createdAt)}
</th>

<th scope="rowgroup" rowSpan={3}>
{file.submittedBy}
{formatDate(file.createdAt) + ' by ' + file.submittedBy}
Copy link
Collaborator

Choose a reason for hiding this comment

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

✔️

Screenshot 2024-11-15 092600

{hasReparsed(file) && <></>}
</th>

<th scope="rowgroup" rowSpan={3}>
Expand Down Expand Up @@ -64,22 +62,7 @@ const CaseAggregatesRow = ({ file }) => {
</th>

<th scope="rowgroup" rowSpan={3}>
{file.summary &&
file.summary.status &&
file.summary.status !== 'Pending' ? (
file.hasError > 0 ? (
<button
className="section-download"
onClick={() => downloadErrorReport(file, errorFileName)}
>
{errorFileName}.xlsx
</button>
) : (
'No Errors'
)
) : (
'Pending'
)}
{getErrorReportStatus(file)}
</th>
</tr>
<tr>
Expand All @@ -99,9 +82,6 @@ export const CaseAggregatesTable = ({ files }) => (
<th scope="col" rowSpan={2}>
Submitted On
</th>
<th scope="col" rowSpan={2}>
Submitted By
</th>
<th scope="col" rowSpan={2}>
File Name
</th>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { useDispatch, useSelector } from 'react-redux'
import { fileUploadSections } from '../../reducers/reports'
import Paginator from '../Paginator'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useDispatch } from 'react-redux'
import {
SubmissionSummaryStatusIcon,
formatDate,
hasReparsed,
getReprocessedDate,
downloadFile,
downloadErrorReport,
getErrorReportStatus,
} from './helpers'

const MonthSubRow = ({ data }) =>
Expand All @@ -22,17 +24,13 @@ const MonthSubRow = ({ data }) =>

const TotalAggregatesRow = ({ file }) => {
const dispatch = useDispatch()
const errorFileName = `${file.year}-${file.quarter}-${file.section}`

return (
<>
<tr>
<th scope="rowgroup" rowSpan={3}>
{formatDate(file.createdAt)}
</th>

<th scope="rowgroup" rowSpan={3}>
{file.submittedBy}
{formatDate(file.createdAt) + ' by ' + file.submittedBy}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Screenshot 2024-11-15 091822_LI

{hasReparsed(file) && <></>}
</th>

<th scope="rowgroup" rowSpan={3}>
Expand All @@ -58,22 +56,7 @@ const TotalAggregatesRow = ({ file }) => {
</th>

<th scope="rowgroup" rowSpan={3}>
{file.summary &&
file.summary.status &&
file.summary.status !== 'Pending' ? (
file.hasError > 0 ? (
<button
className="section-download"
onClick={() => downloadErrorReport(file, errorFileName)}
>
{errorFileName}.xlsx
</button>
) : (
'No Errors'
)
) : (
'Pending'
)}
{getErrorReportStatus(file)}
</th>
</tr>
<tr>
Expand All @@ -93,9 +76,6 @@ export const TotalAggregatesTable = ({ files }) => (
<th scope="col" rowSpan={2}>
Submitted On
</th>
<th scope="col" rowSpan={2}>
Submitted By
</th>
<th scope="col" rowSpan={2}>
File Name
</th>
Expand Down
30 changes: 30 additions & 0 deletions tdrs-frontend/src/components/SubmissionHistory/helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,36 @@ export const downloadErrorReport = async (file, reportName) => {
console.log(error)
}
}
export const hasReparsed = (f) =>
f.latest_reparse_file_meta &&
f.latest_reparse_file_meta.finished_at &&
f.latest_reparse_file_meta.finished_at !== null

export const getReprocessedDate = (f) => f.latest_reparse_file_meta.finished_at

export const getErrorReportStatus = (file) => {
if (
file.summary &&
file.summary.status &&
file.summary.status !== 'Pending'
) {
const errorFileName = `${file.year}-${file.quarter}-${file.section}`
if (file.hasError) {
return (
<button
className="section-download"
onClick={() => downloadErrorReport(file, errorFileName)}
>
{errorFileName}.xlsx
</button>
)
} else {
return 'No Errors'
}
} else {
return 'Pending'
}
}

export const SubmissionSummaryStatusIcon = ({ status }) => {
let icon = null
Expand Down
1 change: 1 addition & 0 deletions tdrs-frontend/src/reducers/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const serializeApiDataFile = (dataFile) => ({
submittedBy: dataFile.submitted_by,
hasError: dataFile.has_error,
summary: dataFile.summary,
latest_reparse_file_meta: dataFile.latest_reparse_file_meta,
})

const initialState = {
Expand Down
Loading