From b6e67221933c6a02e36b289ffa00ca98c73e8c0f Mon Sep 17 00:00:00 2001
From: Markus Scheidgen <markus.scheidgen@gmail.com>
Date: Thu, 28 Mar 2019 14:47:19 +0100
Subject: [PATCH] Fixed bug with missing atoms in search index.

---
 gui/src/components/Repo.js | 2 +-
 nomad/datamodel.py         | 6 ++++++
 tests/test_api.py          | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gui/src/components/Repo.js b/gui/src/components/Repo.js
index 3725ca2ad5..a685261815 100644
--- a/gui/src/components/Repo.js
+++ b/gui/src/components/Repo.js
@@ -8,7 +8,7 @@ import TablePagination from '@material-ui/core/TablePagination'
 import TableRow from '@material-ui/core/TableRow'
 import Paper from '@material-ui/core/Paper'
 import { TableHead, LinearProgress, FormControl, FormControlLabel, Checkbox, FormGroup,
-  FormLabel, IconButton, MuiThemeProvider, Typography, Tooltip, TableSortLabel, ExpansionPanelDetails, ExpansionPanelSummary, ExpansionPanel, Grid, CircularProgress } from '@material-ui/core'
+  FormLabel, IconButton, MuiThemeProvider, Typography, Tooltip, TableSortLabel, ExpansionPanelDetails, ExpansionPanelSummary, ExpansionPanel, Grid } from '@material-ui/core'
 import { compose } from 'recompose'
 import { withErrors } from './errors'
 import AnalyticsIcon from '@material-ui/icons/Settings'
diff --git a/nomad/datamodel.py b/nomad/datamodel.py
index 3b51af46e4..44cb843825 100644
--- a/nomad/datamodel.py
+++ b/nomad/datamodel.py
@@ -148,7 +148,13 @@ class CalcWithMetadata():
 
     def update(self, **kwargs):
         for key, value in kwargs.items():
+            if value is None:
+                continue
+
             if isinstance(value, list):
+                if len(value) == 0:
+                    continue
+
                 if len(value) > 0 and isinstance(value[0], dict) and not isinstance(value[0], utils.POPO):
                     value = list(utils.POPO(**item) for item in value)
             if isinstance(value, dict) and not isinstance(value, utils.POPO):
diff --git a/tests/test_api.py b/tests/test_api.py
index 052da11111..a3d9d7790b 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -226,7 +226,7 @@ class TestUploads:
 
         upload_with_metadata = get_upload_with_metadata(upload)
         assert_upload_files(upload_with_metadata, files.StagingUploadFiles)
-        assert_search_upload(upload_with_metadata)
+        assert_search_upload(upload_with_metadata, additional_keys=['atoms', 'system'])
 
     def assert_published(self, client, test_user_auth, upload_id, proc_infra, with_coe_repo=True, metadata={}):
         rv = client.get('/uploads/%s' % upload_id, headers=test_user_auth)
-- 
GitLab