Skip to content
Snippets Groups Projects

Added if statement to check if metadata already exists.

All threads resolved!
1 file
+ 14
3
Compare changes
  • Side-by-side
  • Inline
@@ -185,10 +185,21 @@ def upload_reading(
@@ -185,10 +185,21 @@ def upload_reading(
metadata = create_reading_metadata(
metadata = create_reading_metadata(
reading=reading, created_by_label=created_by_label
reading=reading, created_by_label=created_by_label
)
)
# TODO: should this check if metadata was already uploaded?
# TODO: should that check occur before calling this method?
# check if metadata already exists before uploading
if metadata is not None:
if metadata is not None:
return factory.create_metadata(metadata=metadata)
prior_metadata = Metadata(
 
category=MetadataCategory.READING,
 
starttime=metadata.starttime,
 
endtime=metadata.endtime,
 
station=metadata.station,
 
)
 
prior_metadata = factory.get_metadata(query=prior_metadata)
 
if len(prior_metadata) != 0:
 
print(" Metadata already exists, skipping upload")
 
pass
 
else:
 
return factory.create_metadata(metadata=metadata)
else:
else:
print(" Absolute set is empty, skipping upload to webservice")
print(" Absolute set is empty, skipping upload to webservice")
pass
pass
Loading