summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-12 12:24:22 -0400
committerJune McEnroe <june@causal.agency>2020-07-12 12:24:22 -0400
commit65f5f3574237791a0da6563c2983dbbcd261f7f9 (patch)
tree9153dfe376b686182e137212773b66689bb99166
parentReorganize code and add earlier messages link (diff)
downloadscooper-65f5f3574237791a0da6563c2983dbbcd261f7f9.tar.gz
scooper-65f5f3574237791a0da6563c2983dbbcd261f7f9.zip
Add events gaps
Diffstat (limited to '')
-rw-r--r--events.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/events.c b/events.c
index 35e2c5b..e9a4f83 100644
--- a/events.c
+++ b/events.c
@@ -16,6 +16,7 @@
 
 #include <err.h>
 #include <inttypes.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sysexits.h>
@@ -158,6 +159,8 @@ enum kcgi_err eventsPage(struct kreq *req) {
 
 	int rows;
 	int result;
+	time_t prevTime = 0;
+	int64_t prevEvent = 0;
 	for (rows = 0; SQLITE_ROW == (result = sqlite3_step(events)); ++rows) {
 		int i = 0;
 		struct Event event = {0};
@@ -195,6 +198,17 @@ enum kcgi_err eventsPage(struct kreq *req) {
 			if (error) return error;
 		}
 
+		if (prevTime && event.time - prevTime >= eventsGap) {
+			error = 0
+				|| khtml_attr(&html, KELEM_TR, KATTR_CLASS, "gap", KATTR__MAX)
+				|| khtml_attr(&html, KELEM_TH, KATTR_COLSPAN, "3", KATTR__MAX)
+				|| khtml_puts(&html, "...")
+				|| khtml_closeelem(&html, 2);
+			if (error) return error;
+		}
+		prevEvent = event.event;
+		prevTime = event.time;
+
 		error = htmlEvent(&html, scope, event);
 		if (error) return error;
 	}