Skip to content

Commit

Permalink
rename perfect -> no_issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fhennig committed Oct 31, 2024
1 parent 049b44f commit 54c8e27
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ enum class ProcessingResult {
/**
* The sequence has no warnings or errors
*/
@JsonProperty("PERFECT")
PERFECT,
@JsonProperty("NO_ISSUES")
NO_ISSUES,

/**
* The sequence has warnings but no errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class SubmissionDatabaseService(
it.map { processingResult ->
when (processingResult) {
ProcessingResult.ERRORS -> SequenceEntriesView.hasErrors
ProcessingResult.PERFECT -> not(
ProcessingResult.NO_ISSUES -> not(
SequenceEntriesView.hasErrors or SequenceEntriesView.hasWarnings,
)
ProcessingResult.WARNINGS -> not(SequenceEntriesView.hasErrors) and
Expand Down Expand Up @@ -768,17 +768,17 @@ class SubmissionDatabaseService(
countBaseQuery.andWhere { SequenceEntriesView.organismIs(organism) }
}

val errorCounts = countBaseQuery.copy().andWhere { SequenceEntriesView.hasErrors }.count()
val warningCounts = countBaseQuery.copy().andWhere {
val errorCount = countBaseQuery.copy().andWhere { SequenceEntriesView.hasErrors }.count()
val warningCount = countBaseQuery.copy().andWhere {
SequenceEntriesView.hasWarnings and not(SequenceEntriesView.hasErrors)
}.count()
val perfectCounts = countBaseQuery.copy().andWhere {
val noIssuesCount = countBaseQuery.copy().andWhere {
not(SequenceEntriesView.hasWarnings or SequenceEntriesView.hasErrors)
}.count()
val processingResultCounts = mapOf(
ProcessingResult.ERRORS to errorCounts.toInt(),
ProcessingResult.WARNINGS to warningCounts.toInt(),
ProcessingResult.PERFECT to perfectCounts.toInt(),
ProcessingResult.ERRORS to errorCount.toInt(),
ProcessingResult.WARNINGS to warningCount.toInt(),
ProcessingResult.NO_ISSUES to noIssuesCount.toInt(),
)
return processingResultCounts
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CitationEndpointsTest(@Autowired private val client: SeqSetCitationsContro
),
statusCounts = mapOf(Status.APPROVED_FOR_RELEASE to 1),
processingResultCounts = mapOf(
ProcessingResult.PERFECT to 0,
ProcessingResult.NO_ISSUES to 0,
ProcessingResult.WARNINGS to 0,
ProcessingResult.ERRORS to 0,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class DeleteSequencesEndpointTest(
equalTo(erroneousSequences.size),
)
assertThat(
convenienceClient.getProcessingResultCount(ProcessingResult.PERFECT) +
convenienceClient.getProcessingResultCount(ProcessingResult.NO_ISSUES) +
convenienceClient.getProcessingResultCount(ProcessingResult.WARNINGS),
equalTo(approvableSequences.size),
)
Expand All @@ -197,7 +197,7 @@ class DeleteSequencesEndpointTest(
equalTo(0),
)
assertThat(
convenienceClient.getProcessingResultCount(ProcessingResult.PERFECT) +
convenienceClient.getProcessingResultCount(ProcessingResult.NO_ISSUES) +
convenienceClient.getProcessingResultCount(ProcessingResult.WARNINGS),
equalTo(approvableSequences.size),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class GetSequencesEndpointTest(
val sequencesInAwaitingApproval = convenienceClient.getSequenceEntries(
username = ALTERNATIVE_DEFAULT_USER_NAME,
statusesFilter = listOf(PROCESSED),
processingResultFilter = listOf(ProcessingResult.ERRORS, ProcessingResult.PERFECT),
processingResultFilter = listOf(ProcessingResult.ERRORS, ProcessingResult.NO_ISSUES),
).sequenceEntries

assertThat(sequencesInAwaitingApproval, hasSize(0))
Expand All @@ -245,14 +245,14 @@ class GetSequencesEndpointTest(

val resultForInAwaitingApprovalPageOne = convenienceClient.getSequenceEntries(
statusesFilter = listOf(PROCESSED),
processingResultFilter = listOf(ProcessingResult.PERFECT, ProcessingResult.WARNINGS),
processingResultFilter = listOf(ProcessingResult.NO_ISSUES, ProcessingResult.WARNINGS),
page = 0,
size = 5,
)

assertThat(resultForInAwaitingApprovalPageOne.sequenceEntries, hasSize(5))
assertThat(resultForInAwaitingApprovalPageOne.statusCounts, hasEntry(PROCESSED, 20))
assertThat(resultForInAwaitingApprovalPageOne.processingResultCounts, hasEntry(ProcessingResult.PERFECT, 10))
assertThat(resultForInAwaitingApprovalPageOne.processingResultCounts, hasEntry(ProcessingResult.NO_ISSUES, 10))
assertThat(resultForInAwaitingApprovalPageOne.processingResultCounts, hasEntry(ProcessingResult.ERRORS, 10))

val resultForInAwaitingApprovalPageTwo = convenienceClient.getSequenceEntries(
Expand Down Expand Up @@ -288,7 +288,7 @@ class GetSequencesEndpointTest(
mapOf(
ProcessingResult.ERRORS to 10,
ProcessingResult.WARNINGS to 0,
ProcessingResult.PERFECT to 10,
ProcessingResult.NO_ISSUES to 10,
),
),
)
Expand Down
2 changes: 2 additions & 0 deletions website/src/components/ReviewPage/ReviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const ReviewCard: FC<ReviewCardProps> = ({
accessToken,
}) => {
const { isLoading, data } = useGetMetadataAndAnnotations(organism, clientConfig, accessToken, sequenceEntryStatus);
// TODO the hook above makes an extra call for each row.
// We want to get all relevant data passed in instead.

return (
<div className='px-3 py-2 relative transition-all duration-500'>
Expand Down
6 changes: 3 additions & 3 deletions website/src/components/ReviewPage/ReviewPage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
receivedStatus,
type SequenceEntryStatus,
type GetSequencesResponse,
perfectProcessingResult,
noIssuesProcessingResult,
warningsProcessingResult,
errorsProcessingResult,
} from '../../types/backend.ts';
Expand Down Expand Up @@ -91,7 +91,7 @@ const emptyStatusCounts = {
};

const emptyProcessingResultCounts = {
[perfectProcessingResult]: 0,
[noIssuesProcessingResult]: 0,
[warningsProcessingResult]: 0,
[errorsProcessingResult]: 0,
};
Expand All @@ -111,7 +111,7 @@ const generateGetSequencesResponse = (sequenceEntries: SequenceEntryStatus[]): G
} else if (sequence.isWarning) {
acc[warningsProcessingResult] = acc[warningsProcessingResult] + 1;
} else {
acc[perfectProcessingResult] = acc[perfectProcessingResult] + 1;
acc[noIssuesProcessingResult] = acc[noIssuesProcessingResult] + 1;
}
return acc;
},
Expand Down
24 changes: 12 additions & 12 deletions website/src/components/ReviewPage/ReviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
type SequenceEntryStatus,
errorsProcessingResult,
warningsProcessingResult,
perfectProcessingResult,
noIssuesProcessingResult,
} from '../../types/backend.ts';
import { type ClientConfig } from '../../types/runtimeConfig.ts';
import { displayConfirmationDialog } from '../ConfirmationDialog.tsx';
Expand Down Expand Up @@ -76,7 +76,7 @@ const InnerReviewPage: FC<ReviewPageProps> = ({ clientConfig, organism, group, a

const hooks = useSubmissionOperations(organism, group, clientConfig, accessToken, toast.error, pageQuery);

const showPerfect = hooks.includedProcessingResults.includes(perfectProcessingResult);
const showNoIssues = hooks.includedProcessingResults.includes(noIssuesProcessingResult);
const showWarnings = hooks.includedProcessingResults.includes(warningsProcessingResult);
const showErrors = hooks.includedProcessingResults.includes(errorsProcessingResult);
const showUnprocessed =
Expand All @@ -100,7 +100,7 @@ const InnerReviewPage: FC<ReviewPageProps> = ({ clientConfig, organism, group, a
});
};

const setShowPerfect = (value: boolean) => setAProcessingResult(perfectProcessingResult, value);
const setShowNoIssues = (value: boolean) => setAProcessingResult(noIssuesProcessingResult, value);
const setShowWarnings = (value: boolean) => setAProcessingResult(warningsProcessingResult, value);
const setShowErrors = (value: boolean) => setAProcessingResult(errorsProcessingResult, value);
const setShowUnprocessed = (value: boolean) => {
Expand Down Expand Up @@ -143,8 +143,8 @@ const InnerReviewPage: FC<ReviewPageProps> = ({ clientConfig, organism, group, a

const errorCount = sequencesData.processingResultCounts[errorsProcessingResult];
const warningCount = sequencesData.processingResultCounts[warningsProcessingResult];
const perfectCount = sequencesData.processingResultCounts[perfectProcessingResult];
const submittableCount = warningCount + perfectCount;
const noIssuesCount = sequencesData.processingResultCounts[noIssuesProcessingResult];
const validCount = warningCount + noIssuesCount;

if (total === 0) {
return (
Expand Down Expand Up @@ -193,7 +193,7 @@ const InnerReviewPage: FC<ReviewPageProps> = ({ clientConfig, organism, group, a
</div>
<div className='border-t-2 border-primary-400 pt-1 h-full mt-6 flex flex-col justify-between'>
<div className='text-gray-500 text-xs mb-auto'>
<span className=''>{submittableCount} </span>
<span className=''>{validCount} </span>
submittable
</div>
<div className='flex gap-6'>
Expand All @@ -207,9 +207,9 @@ const InnerReviewPage: FC<ReviewPageProps> = ({ clientConfig, organism, group, a
<NumberAndVisibility
key='valid'
text='no issues'
countNumber={perfectCount}
setVisibility={setShowPerfect}
visibilityEnabled={showPerfect}
countNumber={noIssuesCount}
setVisibility={setShowNoIssues}
visibilityEnabled={showNoIssues}
/>
</div>
</div>
Expand Down Expand Up @@ -299,7 +299,7 @@ const InnerReviewPage: FC<ReviewPageProps> = ({ clientConfig, organism, group, a
</MenuItems>
</Menu>
)}
{submittableCount > 0 && (
{validCount > 0 && (
<button
className='border rounded-md p-1 bg-primary-600 text-white px-2'
onClick={() =>
Expand All @@ -317,8 +317,8 @@ const InnerReviewPage: FC<ReviewPageProps> = ({ clientConfig, organism, group, a
}
>
<WpfPaperPlane className='inline-block w-4 h-4 -mt-0.5 mr-1.5' />
Release {submittableCount} valid sequence
{submittableCount > 1 ? 's' : ''}
Release {validCount} valid sequence
{validCount > 1 ? 's' : ''}
</button>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions website/src/hooks/useSubmissionOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
inProcessingStatus,
type PageQuery,
receivedStatus,
perfectProcessingResult,
noIssuesProcessingResult,
warningsProcessingResult,
errorsProcessingResult,
} from '../types/backend.ts';
Expand All @@ -28,7 +28,7 @@ export function useSubmissionOperations(
) {
const hooks = useMemo(() => backendClientHooks(clientConfig), [clientConfig]);
const allRelevantStatuses = [receivedStatus, inProcessingStatus, processedStatus];
const allProcessingResults = [perfectProcessingResult, warningsProcessingResult, errorsProcessingResult];
const allProcessingResults = [noIssuesProcessingResult, warningsProcessingResult, errorsProcessingResult];
const [includedStatuses, setIncludedStatuses] = useState<string[]>(allRelevantStatuses);
const [includedProcessingResults, setIncludedProcessingResults] = useState<string[]>(allProcessingResults);
// TODO here I should add the include/exclude warnings thing
Expand Down
4 changes: 2 additions & 2 deletions website/src/types/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const inProcessingStatus = 'IN_PROCESSING';
export const processedStatus = 'PROCESSED';
export const approvedForReleaseStatus = 'APPROVED_FOR_RELEASE';

export const perfectProcessingResult = 'PERFECT';
export const noIssuesProcessingResult = 'NO_ISSUES';
export const warningsProcessingResult = 'WARNINGS';
export const errorsProcessingResult = 'ERRORS';

Expand All @@ -18,7 +18,7 @@ export const sequenceEntryStatusNames = z.union([
export type SequenceEntryStatusNames = z.infer<typeof sequenceEntryStatusNames>;

export const sequenceEntryProcessingResultNames = z.union([
z.literal(perfectProcessingResult),
z.literal(noIssuesProcessingResult),
z.literal(warningsProcessingResult),
z.literal(errorsProcessingResult),
]);
Expand Down

0 comments on commit 54c8e27

Please sign in to comment.