From e80097017192c733e1ffd820ee86c9b65b7719a8 Mon Sep 17 00:00:00 2001
From: Florian Spreckelsen <f.spreckelsen@indiscale.com>
Date: Fri, 7 Feb 2025 15:54:08 +0100
Subject: [PATCH] WIP: Remove some entries from sample exporter

---
 .../scripting/bin/export_sample_csv.py        | 55 +------------------
 1 file changed, 1 insertion(+), 54 deletions(-)

diff --git a/sample-management-custom/caosdb-server/scripting/bin/export_sample_csv.py b/sample-management-custom/caosdb-server/scripting/bin/export_sample_csv.py
index 4f47b48..4b79fdd 100755
--- a/sample-management-custom/caosdb-server/scripting/bin/export_sample_csv.py
+++ b/sample-management-custom/caosdb-server/scripting/bin/export_sample_csv.py
@@ -63,19 +63,6 @@ ERROR_PREFIX = 'Something went wrong: '
 ERROR_SUFFIX = ' Please conatct <a href="mailto:biosamples@geomar.de">biosamples@geomar.de</a> if you encounter this issue.'
 
 
-# Declare mapping of different time/date column names to property names
-TIME_NAME_MAPPINGS = {
-    "date collected start": "time start",
-    "time collected start": "time start",
-    "date collected stop": "time stop",
-    "time collected stop": "time stop",
-    "date sampled start": "time sampled start",
-    "time sampled start": "time sampled start",
-    "date sampled stop": "time sampled stop",
-    "time sampled stop": "time sampled stop",
-}
-
-
 def cached_record(i):
 
     return cached_get_entity_by(eid=i)
@@ -212,29 +199,6 @@ def extract_date_time(record, p):
         return extract_value_as_list(record, p)
 
 
-def extract_date(record, key):
-    if key.lower() in TIME_NAME_MAPPINGS.keys():
-        time_key = TIME_NAME_MAPPINGS[key.lower()]
-    else:
-        time_key = key
-    date_times = extract_date_time(record, time_key)
-    return [isoparse(t).date().isoformat() for t in date_times]
-
-
-def extract_time(record, key):
-    if key.lower() in TIME_NAME_MAPPINGS.keys():
-        time_key = TIME_NAME_MAPPINGS[key.lower()]
-    else:
-        time_key = key
-    date_times = extract_date_time(record, time_key)
-    return [isoparse(t).time().isoformat() for t in date_times]
-
-
-def extract_time_zone(record, key):
-    date_times = extract_date_time(record, "Time start")
-    return [isoparse(t).tzname() for t in date_times]
-
-
 def extract_station_number(record, key):
     source_ev = retrieve_source_event(record)
     return [e.get_property(key).value for e in source_ev if
@@ -377,7 +341,7 @@ def extract_event_url(record, key):
     return None
 
 
-# must be same keys as SPECIAL_TREATMENT
+# must include all keys from SPECIAL_TREATMENT
 EXTRACTORS = {
     "BIS ID": lambda record, key: record.id,
     "Parent BIS ID": extract_parent_sample,
@@ -399,11 +363,6 @@ EXTRACTORS = {
     "Nagoya case number": extract_nagoya_case_number,
     "PDFReport": extract_pdf_id,
     "Subevent": extract_source_event_name,
-    "Time collected start": extract_time,
-    "Time collected stop": extract_time,
-    "Time sampled start": extract_time,
-    "Time sampled stop": extract_time,
-    "Timezone": extract_time_zone,
     "Station ID": extract_station_id,
     "Station number": extract_station_number,
     "Sampling depth start": extract_sampling_depth_start,
@@ -436,14 +395,9 @@ REVERSE_COLUMN_CONVERTER = {
 # List of sample properties to be ignored because they are treated
 # otherwise. Similar, but not identical to SPECIAL TREATMENT.
 IGNORE_KEYS = [
-    "NagoyaCase",
     "Parent Sample",
     "Container",
-    "SourceEvent",
     "Event",
-    "Date",
-    "Sampling depth",
-    "Water depth"
 ]
 
 # Additional list of keys to be ignored when extracting parent sample information
@@ -455,15 +409,8 @@ IGNORE_KEYS_PARENT = IGNORE_KEYS + [
 # the import.
 ADDITIONAL_EXPORTS = [
     "BIS URL",
-    "Date sampled start",
-    "Date sampled stop",
-    "IGSN URL",
-    "IGSN",
     "Parent BIS ID",
     "Storage chain",
-    "Time sampled start",
-    "Time sampled stop",
-    "URL SourceEvent"
 ]
 
 
-- 
GitLab