From 351f6b0f22c50146572bcca54fa3d57e3b467990 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Wed, 4 Sep 2024 13:13:03 +0200 Subject: [PATCH] feat(#712): fix sorting of warning levels with severity 0 --- app/lib/report/pages/report.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/lib/report/pages/report.dart b/app/lib/report/pages/report.dart index d8e34c19..c2d53d9c 100644 --- a/app/lib/report/pages/report.dart +++ b/app/lib/report/pages/report.dart @@ -17,7 +17,7 @@ class ReportPage extends StatelessWidget { int _getSeverityCount(WarningLevelCounts warningLevelCounts, int severity) { return warningLevelCounts.filter( (warningLevelCount) => warningLevelCount.key.severity == severity - ).values.first; + ).values.sum(); } Widget _buildReportPage(BuildContext context, ActiveDrugs activeDrugs) { @@ -49,14 +49,16 @@ class ReportPage extends StatelessWidget { var sortedGenotypes = userGenotypes.sortedBy( (genotypeResult) => genotypeResult.gene ); - final sortedWarningLevels = WarningLevel.values.sortedBy( - (warningLevel) => warningLevel.severity - ); - for (final warningLevel in sortedWarningLevels) { + final sortedWarningLevelSeverities = Set.from( + WarningLevel.values + .sortedBy((warningLevel) => warningLevel.severity) + .map((warningLevel) => warningLevel.severity) + ); + for (final severity in sortedWarningLevelSeverities) { sortedGenotypes = sortedGenotypes.sortedByDescending((genotypeResult) => _getSeverityCount( warningLevelCounts[genotypeResult.gene]!, - warningLevel.severity, + severity, ), ); }