From d6bdf9081110d53483ec68a3f40ae64c6b91d74f Mon Sep 17 00:00:00 2001 From: "Stein A. Hoem" Date: Tue, 15 Oct 2024 14:28:53 +0200 Subject: [PATCH 1/5] FIx #1439 --- Assessments.Frontend.Web/Views/Shared/_Layout.cshtml | 4 ++-- Assessments.Frontend.Web/wwwroot/js/cookies.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Assessments.Frontend.Web/Views/Shared/_Layout.cshtml b/Assessments.Frontend.Web/Views/Shared/_Layout.cshtml index fc78ef43..6554c2ca 100644 --- a/Assessments.Frontend.Web/Views/Shared/_Layout.cshtml +++ b/Assessments.Frontend.Web/Views/Shared/_Layout.cshtml @@ -15,7 +15,7 @@ - + @@ -48,7 +48,7 @@ bruksmønstera til enkeltbrukarar eller annan informasjon som vil kunne krenkje personvernet.

- Artsdatabanken får brukarstatistikk frå Google Analytics. + Artsdatabanken får brukarstatistikk frå Google Analytics og Microsoft Clarity. Det medfører at bruken din av nettsidene våre, inklusiv IP-adressa di, kan bli overført til Google, men vi nyttar Google Analytics sin anonymiseringsfunksjon som sørgjer for at dei siste siffera i brukaren si IP-adresse blir maskert ved innsamling. IP-maskeringa skjer så snart dataa er mottekne av Google Analytics sitt innsamlingsverk, diff --git a/Assessments.Frontend.Web/wwwroot/js/cookies.js b/Assessments.Frontend.Web/wwwroot/js/cookies.js index 8ed76ab4..a5392e53 100644 --- a/Assessments.Frontend.Web/wwwroot/js/cookies.js +++ b/Assessments.Frontend.Web/wwwroot/js/cookies.js @@ -32,6 +32,11 @@ var cookieDurationString = cookieDuration.toUTCString(); // setCookie uses this m.parentNode.insertBefore(a, m); })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); +(function(c,l,a,r,i,t,y){ + c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) }; + t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; + y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); +})(window, document, "clarity", "script", "oizcojljrc"); // expand read more function learnAboutCookies() { @@ -92,6 +97,7 @@ function hasAcceptedCookies() { ga('create', 'UA-74815937-4', { 'cookieExpires': cookieDurationSeconds, 'cookieUpdate': 'false', 'cookieFlags': 'Secure' }); ga('send', 'pageview'); themeCookie(); + window.clarity('consent'); location.reload(); } } @@ -103,6 +109,7 @@ function hasRejectedCookies() { sessionStorage['acceptedcookies'] = acceptedcookies; document.getElementById('heyCookie').style.display = "none"; // TODO: SHOULD LOOP THRU AND DELETE ALL COOKIES. + window.clarity('consent', false); } } From 8484ce365698576f048ef6723c6de06fff2e10bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20S=C3=A6ter?= Date: Fri, 22 Nov 2024 11:46:59 +0100 Subject: [PATCH 2/5] change the formatting for decimal numbers --- .../2023/AssessmentPartials/_CriteriaExplanation.cshtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_CriteriaExplanation.cshtml b/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_CriteriaExplanation.cshtml index 02c45073..b30c40bf 100644 --- a/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_CriteriaExplanation.cshtml +++ b/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_CriteriaExplanation.cshtml @@ -468,15 +468,15 @@ @Constants.AlienSpeciesTables.GrowthRate (λ) - @assessment.MedianLifetimeNumericalEstimationGrowthRate.ToString("N0") + @assessment.MedianLifetimeNumericalEstimationGrowthRate.ToString("G") @Constants.AlienSpeciesTables.EnvironmentVar (σe2) - @assessment.MedianLifetimeNumericalEstimationEnvironmentalVariance?.ToString("N0") + @assessment.MedianLifetimeNumericalEstimationEnvironmentalVariance?.ToString("G") @Constants.AlienSpeciesTables.DemographicVar (σd2) - @assessment.MedianLifetimeNumericalEstimationDemographicVariance?.ToString("N0") + @assessment.MedianLifetimeNumericalEstimationDemographicVariance?.ToString("G") @Constants.AlienSpeciesTables.CarryingCapasity From 04d2c5e9dc6d045076d97967b3095f9c706f8aa2 Mon Sep 17 00:00:00 2001 From: Eirik Date: Mon, 6 Jan 2025 11:37:36 +0100 Subject: [PATCH 3/5] Fix yearfirstrecord #1430 --- .../Infrastructure/DataRepository.cs | 12 ++++++++---- .../2023/AssessmentPartials/_KnowMore.cshtml | 6 +++--- .../appsettings.Development.json | 2 +- .../AlienSpeciesAssessment2023ProfileHelper.cs | 13 +++++++++---- .../AlienSpeciesAssessment2023YearFirstRecord.cs | 10 +++++++++- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Assessments.Frontend.Web/Infrastructure/DataRepository.cs b/Assessments.Frontend.Web/Infrastructure/DataRepository.cs index 6e84c217..0f9c00bf 100644 --- a/Assessments.Frontend.Web/Infrastructure/DataRepository.cs +++ b/Assessments.Frontend.Web/Infrastructure/DataRepository.cs @@ -84,6 +84,10 @@ async Task> DeserializeData() public Task> GetSpeciesAssessments() { + var speciesAssessments = _appCache.GetOrAddAsync(nameof(GetSpeciesAssessments), Get); + + return speciesAssessments; + async Task> Get() { return _options.Value.Species2021.TransformAssessments @@ -93,12 +97,14 @@ async Task> Get() // returnerer modell som allerede er transformert await GetData(DataFilenames.Species2021); } - - return _appCache.GetOrAddAsync($"{nameof(GetSpeciesAssessments)}", Get); } public Task> GetAlienSpeciesAssessments() { + var alienSpeciesAssessments = _appCache.GetOrAddAsync(nameof(GetAlienSpeciesAssessments), Get); + + return alienSpeciesAssessments; + async Task> Get() { return _options.Value.AlienSpecies2023.TransformAssessments @@ -108,8 +114,6 @@ async Task> Get() // returnerer modell som allerede er transformert await GetData(DataFilenames.AlienSpecies2023); } - - return _appCache.GetOrAddAsync($"{nameof(GetSpeciesAssessments)}", Get); } } } \ No newline at end of file diff --git a/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml b/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml index d23727e6..55e56d1f 100644 --- a/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml +++ b/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml @@ -97,9 +97,9 @@ @foreach(var record in Model.Assessment.YearsFirstRecord.ObservedEstablishmentInNorway) { - @record.recordType.DisplayName().ToLowerInvariant() - @Constants.AlienSpeciesTables.FirstObsTableColumn2:@record.year - @Html.Raw(@Constants.AlienSpeciesTables.FirstObsTableColumn3):@( record.isUncertaintyYear ? "ja" : "nei" ) + @record.Item1.DisplayName().ToLowerInvariant() + @Constants.AlienSpeciesTables.FirstObsTableColumn2:@record.Item2 + @Html.Raw(@Constants.AlienSpeciesTables.FirstObsTableColumn3):@( record.Item3 ? "ja" : "nei" ) } diff --git a/Assessments.Frontend.Web/appsettings.Development.json b/Assessments.Frontend.Web/appsettings.Development.json index 127e01e2..a6faa610 100644 --- a/Assessments.Frontend.Web/appsettings.Development.json +++ b/Assessments.Frontend.Web/appsettings.Development.json @@ -14,7 +14,7 @@ "TransformAssessments": false }, "Species2021": { - "TransformAssessments": true + "TransformAssessments": false } } } diff --git a/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs b/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs index bc9fa865..fd50d9e5 100644 --- a/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs +++ b/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs @@ -804,16 +804,16 @@ internal static string GetMedianLifetimeEstimationMethod(string category, string } - internal static List<(AlienSpeciesAssessment2023YearFirstRecordType, int, bool)> GetYearsFirstObserved(RiskAssessment riskAssessment, string establishmentCategory) + internal static List GetYearsFirstObserved(RiskAssessment riskAssessment, string establishmentCategory) { if (establishmentCategory is "A") //species not yet in Norway cannot have observations in Norway { - return new List<(AlienSpeciesAssessment2023YearFirstRecordType, int, bool)>(); + return new List(); } else { - var yearEstablishmentType = new List<(AlienSpeciesAssessment2023YearFirstRecordType, int, bool)>(); + var yearEstablishmentType = new List(); foreach (var firstObservationProperty in riskAssessmentPropertiesFirstObservations) { @@ -834,7 +834,12 @@ internal static string GetMedianLifetimeEstimationMethod(string category, string }; var firstObservationUncertaintyProperty = riskAssessmentProperties.Where(x => x.Name == firstObservationProperty.Name + "Insecure").Single(); bool isUncertaintyYearValue = (bool)firstObservationUncertaintyProperty.GetValue(riskAssessment); - yearEstablishmentType.Add((establishmentTypeName, (int)yearFirstValue, isUncertaintyYearValue)); + yearEstablishmentType.Add(new AlienSpeciesAssessment2023YearFirstRecordItem() + { + Item1 = establishmentTypeName, + Item2 = (int)yearFirstValue, + Item3 = isUncertaintyYearValue + }); } } diff --git a/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs b/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs index f45d8915..3525f208 100644 --- a/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs +++ b/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs @@ -5,9 +5,17 @@ namespace Assessments.Mapping.AlienSpecies.Model { public class AlienSpeciesAssessment2023YearFirstRecord { - public List<(AlienSpeciesAssessment2023YearFirstRecordType recordType, int year, bool isUncertaintyYear)> ObservedEstablishmentInNorway { get; set; } = new(); + public List ObservedEstablishmentInNorway { get; set; } = new(); public string Description { get; set; } + } + + public class AlienSpeciesAssessment2023YearFirstRecordItem + { + public AlienSpeciesAssessment2023YearFirstRecordType Item1 { get; set; } + + public int Item2 { get; set; } + public bool Item3 { get; set; } } } \ No newline at end of file From 9054ab5412d4626a7428f2bae2a0b11c42c956ca Mon Sep 17 00:00:00 2001 From: Eirik Date: Tue, 7 Jan 2025 10:44:42 +0100 Subject: [PATCH 4/5] Adjust names --- .../AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml | 6 +++--- .../Helpers/AlienSpeciesAssessment2023ProfileHelper.cs | 6 +++--- .../Model/AlienSpeciesAssessment2023YearFirstRecord.cs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml b/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml index 55e56d1f..7c90920a 100644 --- a/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml +++ b/Assessments.Frontend.Web/Views/AlienSpecies/2023/AssessmentPartials/_KnowMore.cshtml @@ -97,9 +97,9 @@ @foreach(var record in Model.Assessment.YearsFirstRecord.ObservedEstablishmentInNorway) { - @record.Item1.DisplayName().ToLowerInvariant() - @Constants.AlienSpeciesTables.FirstObsTableColumn2:@record.Item2 - @Html.Raw(@Constants.AlienSpeciesTables.FirstObsTableColumn3):@( record.Item3 ? "ja" : "nei" ) + @record.RecordType.DisplayName().ToLowerInvariant() + @Constants.AlienSpeciesTables.FirstObsTableColumn2:@record.Year + @Html.Raw(@Constants.AlienSpeciesTables.FirstObsTableColumn3):@( record.IsUncertaintyYear ? "ja" : "nei" ) } diff --git a/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs b/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs index fd50d9e5..f5bb4b03 100644 --- a/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs +++ b/Assessments.Mapping/AlienSpecies/Helpers/AlienSpeciesAssessment2023ProfileHelper.cs @@ -836,9 +836,9 @@ internal static List GetYearsFirs bool isUncertaintyYearValue = (bool)firstObservationUncertaintyProperty.GetValue(riskAssessment); yearEstablishmentType.Add(new AlienSpeciesAssessment2023YearFirstRecordItem() { - Item1 = establishmentTypeName, - Item2 = (int)yearFirstValue, - Item3 = isUncertaintyYearValue + RecordType = establishmentTypeName, + Year = (int)yearFirstValue, + IsUncertaintyYear = isUncertaintyYearValue }); } } diff --git a/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs b/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs index 3525f208..1e2c115f 100644 --- a/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs +++ b/Assessments.Mapping/AlienSpecies/Model/AlienSpeciesAssessment2023YearFirstRecord.cs @@ -12,10 +12,10 @@ public class AlienSpeciesAssessment2023YearFirstRecord public class AlienSpeciesAssessment2023YearFirstRecordItem { - public AlienSpeciesAssessment2023YearFirstRecordType Item1 { get; set; } + public AlienSpeciesAssessment2023YearFirstRecordType RecordType { get; set; } - public int Item2 { get; set; } + public int Year { get; set; } - public bool Item3 { get; set; } + public bool IsUncertaintyYear { get; set; } } } \ No newline at end of file From d533178e37040ec50cef775e09a42b698c493a84 Mon Sep 17 00:00:00 2001 From: Eirik Date: Wed, 8 Jan 2025 09:38:52 +0100 Subject: [PATCH 5/5] Move local function --- Assessments.Frontend.Web/Infrastructure/DataRepository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assessments.Frontend.Web/Infrastructure/DataRepository.cs b/Assessments.Frontend.Web/Infrastructure/DataRepository.cs index 0f9c00bf..892644c7 100644 --- a/Assessments.Frontend.Web/Infrastructure/DataRepository.cs +++ b/Assessments.Frontend.Web/Infrastructure/DataRepository.cs @@ -46,6 +46,8 @@ public DataRepository(IAppCache appCache, IConfiguration configuration, IWebHost public Task> GetData(string name) { + return _appCache.GetOrAddAsync($"{nameof(DataRepository)}-{name}", DeserializeData); + async Task> DeserializeData() { var fileName = Path.Combine(_environment.ContentRootPath, Constants.CacheFolder, name); @@ -78,8 +80,6 @@ async Task> DeserializeData() return csv.GetRecords().ToList().AsQueryable(); } - - return _appCache.GetOrAddAsync($"{nameof(DataRepository)}-{name}", DeserializeData); } public Task> GetSpeciesAssessments()