Bläddra i källkod

NOTIFY on roasting_log changes

Neal Wilson 10 år sedan
förälder
incheckning
77b1a9beb4
1 ändrade filer med 12 tillägg och 0 borttagningar
  1. 12
    0
      config/Windows/navigation.xml

+ 12
- 0
config/Windows/navigation.xml Visa fil

@@ -280,6 +280,14 @@ type="push" />
280 280
 			query = query.invalidate();
281 281
 		};
282 282
 		
283
+		/* Asynchronous notifications */
284
+		var DBUpdateNotifications = function() {
285
+			var query = new new QSqlQuery;
286
+			query.exec("CREATE OR REPLACE FUNCTION notify_roasting_log_change() RETURNS TRIGGER AS $$ BEGIN NOTIFY RoastingLogChange; END; $$ LANGUAGE plpgsql");
287
+			query.exec("CREATE TRIGGER notify_roasting_log_change AFTER INSERT OR UPDATE ON roasting_log FOR EACH STATEMENT EXECUTE PROCEDURE notify_roasting_log_change()");
288
+			query = query.invalidate();
289
+		};
290
+		
283 291
 		query = new QSqlQuery();
284 292
 		/* A table keeps track of database versioning information. This table is created
285 293
 		   if required. */
@@ -299,6 +307,10 @@ type="push" />
299 307
 				DBUpdateMultiUser();
300 308
 				DBUpdateHistory();
301 309
 			}
310
+			if(query.value(2) < 3)
311
+			{
312
+				DBUpdateNotifications();
313
+			}
302 314
 		}
303 315
 		else
304 316
 		{

Laddar…
Avbryt
Spara