Fossil SCM

Generate event report in chronological order for an alert text.

drh 2018-06-22 15:57 UTC email-alerts
Commit e02892522ecf7f3e79568a97f33ba5051f54f828caebc64c843e00a6367ec514
1 file changed +9 -4
+9 -4
--- src/email.c
+++ src/email.c
@@ -70,11 +70,11 @@
7070
@ -- 'c4413' means check-in with rid=4413.
7171
@ --
7272
@ CREATE TABLE repository.pending_alert(
7373
@ eventid TEXT PRIMARY KEY, -- Object that changed
7474
@ sentSep BOOLEAN DEFAULT false, -- individual emails sent
75
-@ sentDigest BOOLEAN DEFAULT false -- digest emails sent
75
+@ mtime DATETIME -- when added to queue
7676
@ ) WITHOUT ROWID;
7777
@
7878
@ -- Record bounced emails. If too many bounces are received within
7979
@ -- some defined time range, then cancel the subscription. Older
8080
@ -- entries are periodically purged.
@@ -103,12 +103,13 @@
103103
void email_triggers_enable(void){
104104
if( !db_table_exists("repository","pending_alert") ) return;
105105
db_multi_exec(
106106
"CREATE TRIGGER IF NOT EXISTS repository.email_trigger1\n"
107107
"AFTER INSERT ON event BEGIN\n"
108
- " INSERT INTO pending_alert(eventid)\n"
109
- " SELECT printf('%%.1c%%d',new.type,new.objid) WHERE true\n"
108
+ " INSERT INTO pending_alert(eventid,mtime)\n"
109
+ " SELECT printf('%%.1c%%d',new.type,new.objid),"
110
+ " julianday('now') WHERE true\n"
110111
" ON CONFLICT(eventId) DO NOTHING;\n"
111112
"END;"
112113
);
113114
}
114115
@@ -1341,11 +1342,15 @@
13411342
email_schema();
13421343
blob_init(&out, 0, 0);
13431344
email_header(mAlert, &out);
13441345
if( bActual ){
13451346
Stmt q;
1346
- db_prepare(&q, "SELECT eventid FROM pending_alert");
1347
+ db_prepare(&q,
1348
+ "SELECT eventid FROM pending_alert, event"
1349
+ " WHERE event.objid=substr(pending_alert.eventid,2)+0"
1350
+ " ORDER BY event.mtime"
1351
+ );
13471352
while( db_step(&q)==SQLITE_ROW ){
13481353
email_one_alert(db_column_text(&q,0), mAlert, &out);
13491354
}
13501355
db_finalize(&q);
13511356
}else{
13521357
--- src/email.c
+++ src/email.c
@@ -70,11 +70,11 @@
70 @ -- 'c4413' means check-in with rid=4413.
71 @ --
72 @ CREATE TABLE repository.pending_alert(
73 @ eventid TEXT PRIMARY KEY, -- Object that changed
74 @ sentSep BOOLEAN DEFAULT false, -- individual emails sent
75 @ sentDigest BOOLEAN DEFAULT false -- digest emails sent
76 @ ) WITHOUT ROWID;
77 @
78 @ -- Record bounced emails. If too many bounces are received within
79 @ -- some defined time range, then cancel the subscription. Older
80 @ -- entries are periodically purged.
@@ -103,12 +103,13 @@
103 void email_triggers_enable(void){
104 if( !db_table_exists("repository","pending_alert") ) return;
105 db_multi_exec(
106 "CREATE TRIGGER IF NOT EXISTS repository.email_trigger1\n"
107 "AFTER INSERT ON event BEGIN\n"
108 " INSERT INTO pending_alert(eventid)\n"
109 " SELECT printf('%%.1c%%d',new.type,new.objid) WHERE true\n"
 
110 " ON CONFLICT(eventId) DO NOTHING;\n"
111 "END;"
112 );
113 }
114
@@ -1341,11 +1342,15 @@
1341 email_schema();
1342 blob_init(&out, 0, 0);
1343 email_header(mAlert, &out);
1344 if( bActual ){
1345 Stmt q;
1346 db_prepare(&q, "SELECT eventid FROM pending_alert");
 
 
 
 
1347 while( db_step(&q)==SQLITE_ROW ){
1348 email_one_alert(db_column_text(&q,0), mAlert, &out);
1349 }
1350 db_finalize(&q);
1351 }else{
1352
--- src/email.c
+++ src/email.c
@@ -70,11 +70,11 @@
70 @ -- 'c4413' means check-in with rid=4413.
71 @ --
72 @ CREATE TABLE repository.pending_alert(
73 @ eventid TEXT PRIMARY KEY, -- Object that changed
74 @ sentSep BOOLEAN DEFAULT false, -- individual emails sent
75 @ mtime DATETIME -- when added to queue
76 @ ) WITHOUT ROWID;
77 @
78 @ -- Record bounced emails. If too many bounces are received within
79 @ -- some defined time range, then cancel the subscription. Older
80 @ -- entries are periodically purged.
@@ -103,12 +103,13 @@
103 void email_triggers_enable(void){
104 if( !db_table_exists("repository","pending_alert") ) return;
105 db_multi_exec(
106 "CREATE TRIGGER IF NOT EXISTS repository.email_trigger1\n"
107 "AFTER INSERT ON event BEGIN\n"
108 " INSERT INTO pending_alert(eventid,mtime)\n"
109 " SELECT printf('%%.1c%%d',new.type,new.objid),"
110 " julianday('now') WHERE true\n"
111 " ON CONFLICT(eventId) DO NOTHING;\n"
112 "END;"
113 );
114 }
115
@@ -1341,11 +1342,15 @@
1342 email_schema();
1343 blob_init(&out, 0, 0);
1344 email_header(mAlert, &out);
1345 if( bActual ){
1346 Stmt q;
1347 db_prepare(&q,
1348 "SELECT eventid FROM pending_alert, event"
1349 " WHERE event.objid=substr(pending_alert.eventid,2)+0"
1350 " ORDER BY event.mtime"
1351 );
1352 while( db_step(&q)==SQLITE_ROW ){
1353 email_one_alert(db_column_text(&q,0), mAlert, &out);
1354 }
1355 db_finalize(&q);
1356 }else{
1357

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button