changeset 1911:6ffc372cde1e

Fixed JSON serialization of ISRS codes.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 18 Jan 2019 17:50:25 +0100
parents 146369b1c376
children a24d3b4b7ccd
files pkg/imports/st.go pkg/models/isrs.go
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/st.go	Fri Jan 18 17:17:36 2019 +0100
+++ b/pkg/imports/st.go	Fri Jan 18 17:50:25 2019 +0100
@@ -141,7 +141,7 @@
 // CleanUp of a stretch import is a NOP.
 func (*Stretch) CleanUp() error { return nil }
 
-// Do executes the actual bottleneck import.
+// Do executes the actual stretch import.
 func (st *Stretch) Do(
 	ctx context.Context,
 	importID int64,
@@ -151,6 +151,10 @@
 
 	start := time.Now()
 
+	if st.Date.Time.IsZero() {
+		st.Date = models.Date{start}
+	}
+
 	feedback.Info("Storing stretch '%s'", st.Name)
 
 	if len(st.Countries) == 0 {
--- a/pkg/models/isrs.go	Fri Jan 18 17:17:36 2019 +0100
+++ b/pkg/models/isrs.go	Fri Jan 18 17:50:25 2019 +0100
@@ -43,6 +43,13 @@
 	return nil
 }
 
+func (isrs *Isrs) MarshalJSON() ([]byte, error) {
+	if isrs == nil {
+		return nil, nil
+	}
+	return json.Marshal(isrs.String())
+}
+
 // IsrsFromString converts string representation of isrs code to type Isrs
 func IsrsFromString(isrsCode string) (*Isrs, error) {
 	if len(isrsCode) < 20 {