From 1a9d5af5f6bfb3a32982174e1fcdc6166d81be80 Mon Sep 17 00:00:00 2001 From: Pepijn van Oort Date: Mon, 16 Oct 2023 13:55:12 +0200 Subject: [PATCH] don't write duplicate KPIOutput items to output csv --- FarmmapsKPI/KPIApplication.cs | 4 ++-- FarmmapsKPI/KPIInput.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FarmmapsKPI/KPIApplication.cs b/FarmmapsKPI/KPIApplication.cs index b9f7e69..6b1eec3 100644 --- a/FarmmapsKPI/KPIApplication.cs +++ b/FarmmapsKPI/KPIApplication.cs @@ -83,7 +83,7 @@ namespace FarmmapsKPI private async Task Process(List roots, KPIInput input, StreamWriter sw) { KPIOutput kpio; - KPIOutput kpioPrevious = null; + KPIOutput kpioPrevious = new KPIOutput(); //creates a new empty string downloadFolder = input.DownloadFolder; if (string.IsNullOrEmpty(downloadFolder)) { @@ -271,7 +271,7 @@ namespace FarmmapsKPI dataList = new List { }; kpio = JsonConvert.DeserializeObject(item.Data.ToString()); //Seems sometimes duplicate KPI items are returned. So check that here and only write if this kpio is different from previous - if (kpio != kpioPrevious) + if (kpio.id != kpioPrevious.id) { dataList.Add(kpio.parentName); dataList.Add(kpio.data.area); diff --git a/FarmmapsKPI/KPIInput.json b/FarmmapsKPI/KPIInput.json index 04b9b70..46eff35 100644 --- a/FarmmapsKPI/KPIInput.json +++ b/FarmmapsKPI/KPIInput.json @@ -90,7 +90,7 @@ "name": "Kunstmest strooien", "operationCode": "7", "product": "7360", - "quantity": "400", + "quantity": "200", "status": "3", "to": "2022-05-23T12:34:00", "unit": "kg/ha",