diff pkg/controllers/importqueue.go @ 4748:47922c1a088d

Added a 'changed' column to the import.imports table. Changed is update each time the state changes (TODO: solve this with a trigger). The update script takes as approximation the time of the last log entry connected with the particular import.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 18 Oct 2019 15:34:34 +0200
parents 4394daeea96a
children 1fef4679b07a
line wrap: on
line diff
--- a/pkg/controllers/importqueue.go	Fri Oct 18 15:17:31 2019 +0200
+++ b/pkg/controllers/importqueue.go	Fri Oct 18 15:34:34 2019 +0200
@@ -45,6 +45,7 @@
   imports.id AS id,
   state::varchar,
   enqueued,
+  changed,
   kind,
   username,
   signer,
@@ -273,10 +274,12 @@
 	for rows.Next() {
 		var it models.Import
 		var enqueued time.Time
+		var changed time.Time
 		if err = rows.Scan(
 			&it.ID,
 			&it.State,
 			&enqueued,
+			&changed,
 			&it.Kind,
 			&it.User,
 			&signer,
@@ -290,6 +293,7 @@
 			it.Signer = signer.String
 		}
 		it.Enqueued = models.ImportTime{Time: enqueued.UTC()}
+		it.Changed = models.ImportTime{Time: changed.UTC()}
 		imports = append(imports, &it)
 	}
 
@@ -446,6 +450,7 @@
 	reviewSQL = `
 UPDATE import.imports SET
   state = $1::import_state,
+  changed = CURRENT_TIMESTAMP,
   signer = $2
 WHERE id = $3`