Skip to content

Commit

Permalink
Merge pull request #1419 from Artsdatabanken/bugfix/fixSpeciesGroupFi…
Browse files Browse the repository at this point in the history
…gureCount

Bugfix - fix figure counts
  • Loading branch information
matssa authored Jun 18, 2024
2 parents cb25dbc + 5f91a36 commit d6816d8
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private BarChart GetSpeciesGroups()
Data = distinctSpeciesGroups.Where(x => x is not AlienSpeciesAssessment2023SpeciesGroups.Unknown && !algae.Contains(x) && !crayfish.Contains(x) && !insects.Contains(x)).Select(x => new BarChart.BarChartData
{
Name = x.DisplayName(),
Count = _query.Where(y => y.SpeciesGroup == x).Count()
Count = _query.Where(y => y.SpeciesGroup.DisplayName() == x.DisplayName()).Count()
}).ToList()
};

Expand Down Expand Up @@ -284,6 +284,16 @@ private List<BarChart> GetSpreadWaysIntroduction()

var barCharts = new List<BarChart>();

var uniqueIntroductionPathwaysPerSpecies = new List<string>();

var introductionPathwaysSpecies = _query.Select(y => y.IntroductionAndSpreadPathways.Where(z => z.IntroductionSpread == AlienSpeciesAssessment2023IntroductionPathway.IntroductionSpread.Introduction).Select(z => z.Category).ToArray()).ToList();

foreach (var speciesPathways in introductionPathwaysSpecies)
{
var uniquePathways = speciesPathways.Distinct().ToList();
uniqueIntroductionPathwaysPerSpecies.AddRange( uniquePathways );
};

foreach (var spreadWay in allMainSpreadWays)
{
var barChart = new BarChart()
Expand All @@ -292,7 +302,7 @@ private List<BarChart> GetSpreadWaysIntroduction()
Data = _unfilteredQuery.SelectMany(x => x.IntroductionAndSpreadPathways.Where(y => y.IntroductionSpread == AlienSpeciesAssessment2023IntroductionPathway.IntroductionSpread.Introduction && y.MainCategory == spreadWay)).DistinctBy(x => x.Category).Select(x => new BarChart.BarChartData()
{
Name = x.Category,
Count = _query.SelectMany(y => y.IntroductionAndSpreadPathways.DistinctBy(z => z.Category)).Where(z => z.Category == x.Category && z.IntroductionSpread == AlienSpeciesAssessment2023IntroductionPathway.IntroductionSpread.Introduction).Count()
Count = uniqueIntroductionPathwaysPerSpecies.Where(item => x.Category.Equals(item)).Count()
}).OrderBy(x => x.Name).ToList()
};
barCharts.Add(barChart);
Expand Down

0 comments on commit d6816d8

Please sign in to comment.