From 31bb53fe3136f341d271998e620c7a180b17e0f1 Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan.grewe@g-node.org>
Date: Wed, 12 Aug 2020 13:44:56 +0200
Subject: [PATCH] [Dataset] add construtor arg to pull up from dataset_id

---
 fishbook/frontend/frontend_classes.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fishbook/frontend/frontend_classes.py b/fishbook/frontend/frontend_classes.py
index 2c36d73..4502fdf 100644
--- a/fishbook/frontend/frontend_classes.py
+++ b/fishbook/frontend/frontend_classes.py
@@ -312,11 +312,12 @@ class Dataset:
         return len(Datasets())
 
     @staticmethod
-    def find(min_duration=None, experimenter=None, quality=None, min_date=None, max_date=None, test=False):
+    def find(dataset_id=None, min_duration=None, experimenter=None, quality=None, min_date=None, max_date=None, test=False):
         """Find dataset entries in the database. You may restrict the search by providing the following arguments. All restrictions are connected 
         with a logical AND.
 
         Args:
+            dataset_id (str, optional): the id of the given Dataset, if unique, all other restrictions will be ignored. Defaults to None
             min_duration (float, optional): minimum duration of the recording session, if not given, any length datasets will be returned. Defaults to None.
             experimenter (str, optional): the name of the one who did the recording. The name does not need to be the full name. Defaults to None.
             quality (str, optional): the quality assigned to the dataset during recording (e.g. good, fair, poor). Defaults to None.
@@ -328,6 +329,10 @@ class Dataset:
             int: Count of matching results
         """
         dataset_list = Datasets()
+        if dataset_id:
+            dataset_list = dataset_list & "dataset_id like '%{0:s}%'".format(dataset_id)
+        if len(dataset_list) == 1:
+            return [Dataset(tuple=dataset_list.fetch(as_dict=True)[0])], 1
         if min_duration:
             dataset_list = dataset_list & "duration > %.2f" % min_duration
         if experimenter: