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

Feature/species groups statistics #1373

Merged
merged 19 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
13 changes: 1 addition & 12 deletions Assessments.Frontend.Web/Controllers/RedlistController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ public RedlistController(ArtskartApiService artskartApiService)
public IActionResult RodlisteForArter() => View("Species/Rodlisteforarter");

private static readonly Dictionary<string, JObject> _resourceCache = new();
private static readonly Dictionary<string, string> _allAreas = Constants.AllAreas;
private static readonly Dictionary<string, string> _allCriterias = Constants.AllCriterias;
private static readonly Dictionary<string, string> _allEuropeanPopulationPercentages = Constants.AllEuropeanPopulationPercentages;
private readonly ArtskartApiService _artskartApiService;


[Route("2021")]
public async Task<IActionResult> Index2021([FromQueryAttribute] RL2021ViewModel viewModel, int? page, bool export)
{
Expand Down Expand Up @@ -73,8 +69,6 @@ public async Task<IActionResult> Index2021([FromQueryAttribute] RL2021ViewModel

var query = await DataRepository.GetSpeciesAssessments();

ViewBag.AllTaxonRanks = Helpers.GetAllTaxonRanks();

// Søk
if (!string.IsNullOrEmpty(viewModel.Name))
{
Expand All @@ -99,8 +93,6 @@ public async Task<IActionResult> Index2021([FromQueryAttribute] RL2021ViewModel
// Filter

// Areas
ViewBag.AllAreas = _allAreas;

if (viewModel.Area?.Any() == true)
query = query.Where(x => viewModel.Area.Contains(x.AssessmentArea));

Expand All @@ -111,8 +103,6 @@ public async Task<IActionResult> Index2021([FromQueryAttribute] RL2021ViewModel
query = query.Where(x => !string.IsNullOrEmpty(x.Category) && viewModel.Category.Any(y => x.Category.Contains(y)));

// Criterias
ViewBag.AllCriterias = _allCriterias;

if (viewModel.Criterias?.Any() == true)
query = query.Where(x => !string.IsNullOrEmpty(x.CriteriaSummarized) && viewModel.Criterias.Any(y => x.CriteriaSummarized.Contains(y)));

Expand Down Expand Up @@ -144,7 +134,6 @@ public async Task<IActionResult> Index2021([FromQueryAttribute] RL2021ViewModel
query = query.Where(x => viewModel.TaxonRank.Contains(x.TaxonRank));

// European population percentages
ViewBag.AllEuroPop = _allEuropeanPopulationPercentages;
string[] chosenEuropeanPopulation = Helpers.FindEuropeanPopProcentages(viewModel.EuroPop);

if (chosenEuropeanPopulation?.Any() == true)
Expand Down Expand Up @@ -454,4 +443,4 @@ private static async Task<JObject> GetResource(string resourcePath)
return jObject;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Assessments.Frontend.Web.Models;
using System;
using System.Linq;
using Assessments.Frontend.Web.Infrastructure;
using static Assessments.Frontend.Web.Infrastructure.FilterHelpers;

namespace Assessments.Frontend.Web.Infrastructure.AlienSpecies
{
public class FilterHelpers : IFilter<AlienSpeciesListParameters>
public class AlienSpeciesFilterHelpers : IFilter<AlienSpeciesListParameters>
{
public string IGetActiveFilters(string filterType, AlienSpeciesListParameters parameters)
{
Expand All @@ -26,7 +28,7 @@ public string[] IGetActiveSelectionElement(AlienSpeciesListParameters parameters
return GetActiveSelectionElement(parameters);
}

public string IGetChipText(string filter, Filter.FilterItem[] filterItems)
public string IGetChipText(string filter, FilterItem[] filterItems)
{
return GetChipText(filter, filterItems);
}
Expand Down Expand Up @@ -230,11 +232,11 @@ public static string[] GetActiveSelectionElement(AlienSpeciesListParameters para
return selectionlist;
}

public static string GetChipText(string filter, Filter.FilterItem[] filterItems)
public static string GetChipText(string filter, FilterItem[] filterItems)
{
for (int i = 0; i < filterItems.Length; i++)
{
Filter.FilterItem item = filterItems[i];
FilterItem item = filterItems[i];
if (item.NameShort == filter)
{
return item.Name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static Assessments.Frontend.Web.Infrastructure.FilterHelpers;

namespace Assessments.Frontend.Web.Infrastructure.AlienSpecies
{
public class AlienSpeciesHelpers
{
public static Filter.FilterItem GetSpeciesGroup(Filter.FilterItem[] speciesGroups, string speciesGroupName)
public static FilterItem GetSpeciesGroup(FilterItem[] speciesGroups, string speciesGroupName)
{
foreach (var speciesGroup in speciesGroups)
{
Expand Down Expand Up @@ -38,7 +39,7 @@ public static string GetSpeciesGroupByShortName(string shortName)

foreach (var species in speciesGroups)
{
Filter.FilterItem speciesGroup = species;
FilterItem speciesGroup = species;
if (speciesGroup.NameShort == shortName)
{
return speciesGroup.Name;
Expand Down
Loading
Loading